This is a hard question... Like really hard to answer.
First suggestion
Purchase a hardcopy of "Game Engine Architecture" by Jason Gregory or a book similar to it. And read it, write down notes, summarize what you learn in a notebook etc... (this is a 1200 page book). You have a lot of learning to do.
The mechanics
There are multiple ways to do what you want to do from single thread processing to multi-thread (parallel) processing.
I would start by making it a single threaded process. Have a function that performs all required physics engine calculations for a single time step.
Then have a function that performs all required game logic calculations for a single time step.
(Or reverse the order if you want to)
While you are writing both functions, make certain to design them so that you can place either one on top or bottom... Also, also you want to design them so that if they were to to run at the same time it wouldn't break things...
Then add in message queues to communicate from your game logic to your physics Engine...
Assuming that all of your step sizes are the same...
class PhysicsEngine:
private:
# reference to a message queue, PhysicsEngine does not own this.
MessageQueue<>& message_queue
# reference to game object list. Physics Engine does not own this.
list<GameObjects>& game_objects
void step() {
#! do one time step of calculations for your game engine stuff. read the
# message_queue and apply it's effects to the relevant game_object.
}
class GameLogic:
# reference to a message queue, GameLogic does not own this.
MessageQueue<>& message_queue
# reference to game object list. GameLogic does not own this.
list<GameObjects>& game_objects
void step() {
#! do one time step of game play logic...
# Read user input, AI calculations etc..
}
void main() {
for (;;) {
game_logic.step()
physics_engine.step()
}
}
If you do a good enough job separating the game logic and game engine's area of concerns you should be able to split the 2 into a multi threaded environment without any extra work. Make a game logic thread, and a game engine thread. More work can be done to further parallelize the computation, but that starts becoming complicated.. Could put the AI on its own thread... multi thread the physics calculations (Which is by itself a multi person/multi-year million dollar project).