I'm trying to learn more about multithreading and am a little confused.
Currently, I'm using Ogre3D and I'm processing my game entities asynchronously. This means each entity is writing to Ogre::SceneNode asynchronously whenever its position changes:
void processMyGameEntity(Entity& e)
{
Vector3 newPosition = doFancyMovementCode(e);
e.sceneNode->setPosition(newPosition);
}
// ... elsewhere
void Game::updateGame()
{
for(auto& entity : m_EntityList)
this->threadPool.push(processMyGameEntity(entity));
} I know Ogre3D is using boost.thread in the background for rendering, so it is asynchronously reading from scene nodes, but I'm not synchronising when writing to the scenenodes. Why is this working fine? Is it safe for me to continue doing this?
Another question I have: The thread pool I'm using uses std::thread, but Ogre3D is using boost::thread. How do I synchronise objects being shared between the two?