vendredi 27 février 2015

Threading a non-member function


I don't understand the execution flow of the following code:



main()
{
...
while(TRUE)
{
string verb = readCommand();

if (verb == IPC_VERB_CREATE)
{
if (NULL == m_pipeline)
{
m_pipeline = new Pipeline(argv);
boost::thread *pipelineThread = new boost::thread(boost::bind(&Pipeline::run, m_pipeline));
}
}
else if (verb == IPC_VERB_PLAY)
{
m_pipeline->play();
}
else if (verb == IPC_VERB_PAUSE)
{
m_pipeline->pause();
}
}
...
}


When I execute the IPC_VERB_CREATE, the run() function is not executing. Once I make another call in this loop to play(), the run() function continues and then play() is executed.


I realize that this may be a pretty bad model, but I am just experimenting at this point. At a minimum I would expect run() to execute immediately. Why isn't it running until the second call?




Aucun commentaire:

Enregistrer un commentaire