Example #1
0
/*
 ================================================================================
 ClassifyWorker::run
 ================================================================================
 */
void ClassifyWorker::run()
{
   Glib::Mutex::Lock internal_lock(internal_mutex);
   
   // internal copies
   FenceType thisfence;
   
   while(!stopFlag)
   {
      for(currentjob = profile->popNextClassify(); currentjob.second == 255 && !stopFlag; currentjob = profile->popNextClassify())
         classify_condition.wait(internal_mutex);
      
      if(!stopFlag)
      {
         thisfence = currentjob.first;
         
         internal_lock.release();
         profile->classify(thisfence.first, thisfence.second, currentjob.second);
         internal_lock.acquire();
         
         currentjob.second = 255;
         profile->clearProcessingFence();
         sig_done();
      }
   }
}
Example #2
0
/*
 ================================================================================
 ClassifyWorker::stop
 ================================================================================
 */
void ClassifyWorker::stop()
{
   Glib::Mutex::Lock internal_lock(internal_mutex);
   
   stopFlag = true;
   classify_condition.signal();
}
Example #3
0
 void thread::interrupt()
 {
     detail::thread_data_ptr const local_thread_info=(get_thread_info)();
     if(local_thread_info)
     {
         lock_guard<mutex> lk(local_thread_info->data_mutex);
         local_thread_info->interrupt_requested=true;
         if(local_thread_info->current_cond)
         {
             boost::pthread::pthread_mutex_scoped_lock internal_lock(local_thread_info->cond_mutex);
             BOOST_VERIFY(!pthread_cond_broadcast(local_thread_info->current_cond));
         }
     }
 }
Example #4
0
 void wait(lock_type& m)
 {
     int res=0;
     {
         detail::interruption_checker check_for_interruption(&cond);
         {
             boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
             m.unlock();
             res=pthread_cond_wait(&cond,&internal_mutex);
         }
         m.lock();
     }
     if(res)
     {
         boost::throw_exception(condition_error());
     }
 }
bool EventManager::doOperate()
{
	infolog << "New Tick";
	//! \todo rename InternalMutex to OperationMutex or something
	//! InternalMutex is only for DoOperate function ?
	boost::try_mutex::scoped_try_lock internal_lock(mInternalMutex); 
	if (!internal_lock.owns_lock())
	{
		return false;
	}

	// Aquire all necessary Locks
	boost::mutex::scoped_lock scoped_lock(mEventChannelListMutex);

	bool didWork = false;
	for (size_t i = 0; i < mThreadCount; ++i)
	{
		BaseEventPool* pool;
		while ((pool = mEventChannelList[i]->getPublishedEventPool()))
		{
			didWork = true;
			transmitPool(pool); // transmit to networkchannels

			// transmit to all other threads
			for (size_t j = 0; j < mThreadCount; ++j)
			{
				if (j != i)
				{
					BaseEventPool* poolClone = requestPool();
					pool->copyTo(poolClone);
					mEventChannelList[j]->receiveEventPool(poolClone);
				}
			}

			// we don't need this pool anymore
			freePool(pool);
		}
	}
	return didWork;
}
            entry_ptr get_wait_entry()
            {
                boost::lock_guard<boost::mutex> internal_lock(internal_mutex);

                if(!wake_sem)
                {
                    wake_sem=detail::win32::create_anonymous_semaphore(0,LONG_MAX);
                    BOOST_ASSERT(wake_sem);
                }

                detail::interlocked_write_release(&total_count,total_count+1);
                if(generations.empty() || generations.back()->is_notified())
                {
                    entry_ptr new_entry(new list_entry(wake_sem));
                    generations.push_back(new_entry);
                    return new_entry;
                }
                else
                {
                    generations.back()->add_waiter();
                    return generations.back();
                }
            }
Example #7
0
 bool timed_wait(lock_type& m,boost::system_time const& wait_until)
 {
     struct timespec const timeout=detail::get_timespec(wait_until);
     int res=0;
     {
         detail::interruption_checker check_for_interruption(&cond);
         {
             boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
             m.unlock();
             res=pthread_cond_timedwait(&cond,&internal_mutex,&timeout);
         }
         m.lock();
     }
     if(res==ETIMEDOUT)
     {
         return false;
     }
     if(res)
     {
         boost::throw_exception(condition_error());
     }
     return true;
 }
Example #8
0
 inline void condition_variable::notify_all()
 {
     boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
     BOOST_VERIFY(!pthread_cond_broadcast(&cond));
 }
Example #9
0
 void notify_all()
 {
     boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
     BOOST_VERIFY(!pthread_cond_broadcast(&cond));
 }
Example #10
0
 void notify_one()
 {
     boost::pthread::pthread_mutex_scoped_lock internal_lock(&internal_mutex);
     BOOST_VERIFY(!pthread_cond_signal(&cond));
 }
Example #11
0
/*
 ================================================================================
 ClassifyWorker::getCurrentJob

 Retrieve current job from this thread
 ================================================================================
 */
ClassificationJob ClassifyWorker::getCurrentJob()
{
   Glib::Mutex::Lock internal_lock(internal_mutex);
   
   return currentjob;
}
Example #12
0
 void wait(L& lock)
 {  
    ipcdetail::internal_mutex_lock<L> internal_lock(lock);
    m_condition.wait(internal_lock);
 }
Example #13
0
 bool timed_wait(L& lock, const boost::posix_time::ptime &abs_time, Pr pred)
 {
    ipcdetail::internal_mutex_lock<L> internal_lock(lock);
    return m_condition.timed_wait(internal_lock, abs_time, pred);
 }