After reading lots of tech papers/blogs on C++11 threads I redesigned the way the engine handles threading.
Developers can now change threads manually per Scene, each pipeline : Move, Optimise are now batch threaded for better performance. after lots of testing this approch seems to work better under heavy load and being scalable its my new method of choice.
Here is some code from the engine that creates threads based on nodes.
Developers can now change threads manually per Scene, each pipeline : Move, Optimise are now batch threaded for better performance. after lots of testing this approch seems to work better under heavy load and being scalable its my new method of choice.
Here is some code from the engine that creates threads based on nodes.
void lsNode::MoveThread( lsScene* scn, lsOpenGL* opengl, double delta )
{
#ifdef VORTX_DEBUG_NODES
cout << "lsNode::MoveThred() ********************************" << endl;
#endif
vector<thread> th;
lsNode *ptr;
int threads = 1;
int tc = 0;
// Threads
if( scn )
{
threads = scn->getThreads();
} else
{
threads = thread::hardware_concurrency() * 2;
}
// cycle through child and its next nodes
ptr = getNode_list();
while( ptr )
{
// Add thread
th.push_back( thread( &lsNode::Move, ptr, scn, opengl, delta ) );
tc++;
// check our thread count
if(( tc >= threads )||( ptr->getNext_node() == NULL ))
{
#ifdef VORTX_DEBUG_NODETHREADS
// debug
cout << "lsNode::MoveThread - Thread count : " << tc << endl;
#endif
// Join and wait
for( auto &t : th )
{
t.join();
}
// clean up
th.clear();
tc = 0;
}
ptr = ptr->getNext_node();
}
// pass it on
if( getNode_list() ) getNode_list()->MoveThread( scn, opengl, delta );
if( getNext_node() ) getNext_node()->MoveThread( scn, opengl, delta );
}
Create a custom theme





I should also add I have my event system working with the new threads. All core events are on a scene by scene basis, e.g. if a scene node wants to delete itself because its life is over, it must add an event to do so. Game events will work on a Level basis.