コード例 #1
0
ファイル: thread_qtthreads.cpp プロジェクト: ademko/scopira
    virtual void run(void) {
      int i;

      {
        locker bb(outmut);
        fprintf(stderr,"PROD: starting up\n");
      }
      for (i=1; i<max; i++) {
        {
          locker bb(outmut);
          fprintf(stderr,"PROD: starting loop\n");
        }
        thread::sleep(500);
        {
          locker cc(dmut);

          {
            locker bb(outmut);
            fprintf(stderr,"PROD: %d\n", i);
          }
          data = i*10;
          dsem.notify();  // notify one
        }
      }
      {
        locker bb(outmut);
        fprintf(stderr,"PROD: shuttin down\n");
      }
    }
コード例 #2
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;
	}
コード例 #3
0
	void put( T const& t)
	{
		typename node_type::ptr new_node( new node_type() );
		{
			mutex::scoped_lock lk( tail_mtx_);

			if ( ! active_() )
				throw std::runtime_error("queue is not active");

			tail_->va = t;
			tail_->next = new_node;
			tail_ = new_node;
		}
		not_empty_cond_.notify_one();
	}
コード例 #4
0
ファイル: sccs.hpp プロジェクト: StefanReinhardt/framework
		//must be the last call from the runtime_node
		void remove_node( runtime_node* n )
		{
			typename mutex::scoped_lock g(m_);
			typename nodes::iterator it;
			for( it = n_.begin(); it != n_.end(); ++it )
			{
				if( it->second.get() == n )
				{
					del_[n] = it->second;
					n_.erase(it);
					c_.notify_all();
					return;
				}
			}
			assert( 0 ); //node not found
		}
コード例 #5
0
ファイル: thread_qtthreads.cpp プロジェクト: ademko/scopira
    virtual void run(void) {
      int i, v;

      for (i=0; i<max; i++) {
        {
          locker kk(dmut);
          dsem.wait(dmut);
          v = data;
        }
        {
          locker l(outmut);
          fprintf(stderr, "Got data %s: %d\n", name, v);
        }
        thread::sleep(1000);
      }
    }
コード例 #6
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;
	}
コード例 #7
0
	void deactivate()
	{
		mutex::scoped_lock lk( head_mtx_);
		deactivate_();
		not_empty_cond_.notify_all();
	}
コード例 #8
0
ファイル: shared_state.hpp プロジェクト: 654894017/fiberproxy
 void mark_ready_and_notify_()
 {
     ready_ = true;
     waiters_.notify_all();
 }
コード例 #9
0
ファイル: condition.cpp プロジェクト: zhoujunpei/MINI-SQL
condition::condition(const condition &cond)
	: rightSide(cond.getRightSide()), dataType(cond.getDataType()),
	leftSide(cond.getLeftSide()), logicRelation(cond.getLogicRelation())
{
}