Exemplo n.º 1
0
	bool take( value_type & va, chrono::system_clock::time_point const& abs_time)
	{
		mutex::scoped_lock lk( head_mtx_);
		bool empty = empty_();
		if ( ! active_() && empty)
			return false;
		if ( empty)
		{
		try
		{
				while ( active_() && empty_() )
                {
					if ( ! not_empty_cond_.timed_wait( lk, abs_time) )
                        return false;
                }
		}
		catch ( fiber_interrupted const&)
		{ return false; }
		}
		if ( ! active_() && empty_() )
			return false;
		swap( va, head_->va);
		pop_head_();
		return va;
	}
void
SCOCacheMountPoint::newMountPointStage1_()
{
    LOG_TRACE(path_);

    if (!fs::exists(path_))
    {
        throw fungi::IOException("MountPoint does not exist",
                                 path_.string().c_str(),
                                 ENOENT);
    }
    else
    {
        if (!empty_())
        {
            throw fungi::IOException("MountPoint not empty",
                                     path_.string().c_str(),
                                     EEXIST);
        }
    }

    validateParams_();
    bu::basic_random_generator<boost::mt19937> uuidgen;
    uuid_ = uuidgen();

    LOG_DEBUG(path_ << ": creation stage 1 succeeded");
}
Exemplo n.º 3
0
	bool try_take( value_type & va)
	{
		mutex::scoped_lock lk( head_mtx_);
		if ( empty_() )
			return false;
		swap( va, head_->va);
		pop_head_();
		return va;
	}
Exemplo n.º 4
0
    bool dequeue( msg_type & msg, boost::xtime const& xt)
    {
      typename boost::mutex::scoped_lock lock( mtx_);
      if ( active_ == false && empty_() ) return false;
      not_empty_cond_.timed_wait( 
				 lock,
				 xt,
				 boost::bind(
					     & Queue< T, Q >::consumers_activate_,
					     this) );
      if ( empty_() )
	msg.reset();
      else
	dequeue_( msg);
      if ( active_ == true && queue_.size() <= low_water_mark_)
	not_full_cond_.notify_one();
      return msg ? true : false;
    }
Exemplo n.º 5
0
    bool dequeue( msg_type & msg)
    {
      typename boost::mutex::scoped_lock lock( mtx_);
      if ( active_ == false && empty_() ) return false;
      while (empty_() ){
	not_empty_cond_.wait( 
			     lock,
			     boost::bind(
					 & Queue< T, Q >::consumers_activate_,
					 this) );
      }
      dequeue_( msg);
      if ( active_ == true && queue_.size() <= low_water_mark_) {
	
	not_full_cond_.notify_one();
      }
      return msg ? true : false;
    }
Exemplo n.º 6
0
	bool try_take_( callable & ca)
	{
		if ( empty_() )
			return false;
		callable tmp( queue_.top().ca);
		queue_.pop();
		ca.swap( tmp);
		return ! ca.empty();
	}
Exemplo n.º 7
0
Runnable* QueueOfRunnables::get_with_timeout(long timeout)
{
 if(empty() && !destructed_) {
    oneElementAppear_.wait(timeout);
 }
 if (destructed_) {
   throw Destructed();
 }
 MutexLocker guard(arrivedMutex_);
 return  empty_() ? NULL : real_get_();
}
Exemplo n.º 8
0
	bool take( value_type & va)
	{
		mutex::scoped_lock lk( head_mtx_);
		bool empty = empty_();
		if ( ! active_() && empty)
			return false;
		if ( empty)
		{
		try
		{
				while ( active_() && empty_() )
					not_empty_cond_.wait( lk);
		}
		catch ( fiber_interrupted const&)
		{ return false; }
		}
		if ( ! active_() && empty_() )
			return false;
		swap( va, head_->va);
		pop_head_();
		return va;
	}
Exemplo n.º 9
0
Runnable* QueueOfRunnables::try_get()
{
 MutexLocker guard(arrivedMutex_);
 return  empty_() ? NULL : real_get_();
}
Exemplo n.º 10
0
	bool empty() const
	{
		mutex::scoped_lock lk( head_mtx_);
		return empty_();
	}
Exemplo n.º 11
0
 bool consumers_activate_() const
 { return active_ == false || ! empty_(); }
Exemplo n.º 12
0
 bool empty()
 { 
   typename boost::mutex::scoped_lock lock( mtx_);
   return empty_(); 
 }
Exemplo n.º 13
0
	bool empty() const
	{
		shared_lock< shared_mutex > lk( mtx_);
		return empty_();
	}
Exemplo n.º 14
0
 bool empty() const
 {
     // Non-virtual interface
     return empty_();
 }