Ignore:
Timestamp:
Oct 23, 2014, 4:33:11 PM (10 years ago)
Author:
Frederik Heber <heber@…>
Children:
fff8fc
Parents:
23b6cf
git-author:
Frederik Heber <heber@…> (09/03/14 17:21:08)
git-committer:
Frederik Heber <heber@…> (10/23/14 16:33:11)
Message:

Added extra flag run_thread_running to ActionQueue.

  • helgrind admonished race conditions when thread is joined. This did not fix them but should be safer as we cannot know whether the other thread has already been started when suddenly shutting down molecuilder due to an exception.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Actions/ActionQueue.cpp

    r23b6cf r9a4949  
    6767    lastActionOk(true),
    6868    run_thread_isIdle(true),
     69    run_thread_running(false),
    6970    run_thread(boost::bind(&ActionQueue::run, this))
    7071#endif
     
    156157void ActionQueue::run()
    157158{
     159  {
     160    boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle);
     161    run_thread_running = true;
     162  }
    158163  bool Interrupted = false;
    159164  do {
     
    175180    bool status = (CurrentAction != actionqueue.size());
    176181    mtx_queue.unlock();
    177     while (status) {
     182    while ((status) && (!Interrupted)) {
    178183      //      boost::this_thread::disable_interruption di;
    179184      // access actionqueue, hence using mutex
     
    228233//    LOG(1, "DEBUG: End of ActionQueue's run() loop.");
    229234  } while (!Interrupted);
     235  {
     236    boost::lock_guard<boost::mutex> lock(mtx_run_thread_isIdle);
     237    run_thread_running = false;
     238  }
    230239}
    231240#endif
     
    245254{
    246255  boost::unique_lock<boost::mutex> lock(mtx_run_thread_isIdle);
    247   while(!run_thread_isIdle)
    248   {
    249       cond_idle.wait(lock);
    250   }
     256  if (run_thread_running)
     257    while(!run_thread_isIdle)
     258    {
     259        cond_idle.wait(lock);
     260    }
    251261}
    252262#endif
Note: See TracChangeset for help on using the changeset viewer.