当前位置: 首页>>代码示例>>C++>>正文


C++ condition_variable_any::notify_all方法代码示例

本文整理汇总了C++中std::condition_variable_any::notify_all方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable_any::notify_all方法的具体用法?C++ condition_variable_any::notify_all怎么用?C++ condition_variable_any::notify_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在std::condition_variable_any的用法示例。


在下文中一共展示了condition_variable_any::notify_all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: unlock_write

//---------------------------------------------------------------------------
//  function : unlock_write
/// @brief this function unlock the write operation
//---------------------------------------------------------------------------
void unlock_write( void)
{   //-------------------------- begin --------------------
    std::unique_lock <spinlock> UL ( spl);
    assert ( tid == this_id() and nwrite > 0)  ;
    nwrite -- ;
    if ( nwrite == 0 )
    {   cv_write.notify_all() ;
        cv_read.notify_all() ;
    };
};
开发者ID:fjtapia,项目名称:countertree_2.0,代码行数:14,代码来源:mutex_data.hpp

示例2: signals

void signals()
{
    std::this_thread::sleep_for(std::chrono::milliseconds(120));
    std::cerr << "Notifying...\n";
    cv.notify_all();
    std::this_thread::sleep_for(std::chrono::milliseconds(100));
    i = 1;
    std::cerr << "Notifying again...\n";
    cv.notify_all();
}
开发者ID:CCJY,项目名称:coliru,代码行数:10,代码来源:main.cpp

示例3: on_connected

 void on_connected()
 {
     _lock.lock();
     _cond.notify_all();
     connect_finish = true;
     _lock.unlock();
 }
开发者ID:ElvisZuo,项目名称:Socket.IO,代码行数:7,代码来源:main.cpp

示例4: unlock_read

//---------------------------------------------------------------------------
//  function :  unlock_read
/// @brief This function unlock the read operation
//---------------------------------------------------------------------------
void unlock_read ( void)
{   //-------------------------- begin --------------------
    std::unique_lock <spinlock> UL ( spl);
    assert ( nread > 0  );
    nread--;
    if ( nread == 0 ) cv_no_readers.notify_all() ;
};
开发者ID:fjtapia,项目名称:countertree_2.0,代码行数:11,代码来源:mutex_data.hpp

示例5: on_open

 // 接続時に呼び出されるイベントリスナ
 void on_open() {
   std::cout << "接続しました。" << std::endl;
   std::unique_lock<std::mutex> lock(sio_mutex);
   is_connected = true;
   // 接続処理が終わったのち、待っているメインスレッドを起こす
   sio_cond.notify_all();
 }
开发者ID:llamerada-jp,项目名称:socket.io-cpp-client-sample,代码行数:8,代码来源:client.cpp

示例6: signals

void signals()
{
    std::this_thread::sleep_for(std::chrono::seconds(1));
    {
        std::lock_guard<std::mutex> lk(cv_m);
        std::cout << "Notifying...\n";
    }
    cv.notify_all();
 
    std::this_thread::sleep_for(std::chrono::seconds(1));
 
    {
        std::lock_guard<std::mutex> lk(cv_m);
        i = 1;
        std::cout << "Notifying again...\n";
    }
    cv.notify_all();
}
开发者ID:CCJY,项目名称:coliru,代码行数:18,代码来源:main.cpp

示例7: set

	void set()
	{
		flag.store(true, std::memory_order_relaxed);
		std::lock_guard<std::mutex> lk(set_clear_mutex);
		if (thread_cond)
			thread_cond->notify_all();
		else if (thread_cond_any)
			thread_cond_any->notify_all();
	}
开发者ID:DevStarSJ,项目名称:Study,代码行数:9,代码来源:ch.09.02.05.handling_interrupt.cpp

示例8: unlock

		void unlock() {
			if ( --counter == 0 ) {
				cv.notify_all();
			} else { 
				std::unique_lock<sync_object_type>    barrier_lock(sync);
				while(counter != 0)
					cv.wait_for(barrier_lock, std::chrono::milliseconds(1));
			}
		}
开发者ID:SergeyMalashenko,项目名称:OCTree,代码行数:9,代码来源:thread.hpp

示例9: insert

  void insert(T t) {
    std::unique_lock<M> lock{mutex};

    producers.wait(lock, [this]() { return begin != (end + 1) % SIZE; });

    buffer[end] = t;
    end = (end + 1) % SIZE;

    consumers.notify_all();
  }
开发者ID:Mateuszd6,项目名称:uni-concurrent,代码行数:10,代码来源:producer_consumer_test.cpp

示例10: extract

  T extract() {
    std::unique_lock<M> lock{mutex};

    consumers.wait(lock, [this]() { return begin != end; });

    T t = buffer[begin];
    begin = (begin + 1) % SIZE;

    producers.notify_all();

    return t;
  }
开发者ID:Mateuszd6,项目名称:uni-concurrent,代码行数:12,代码来源:producer_consumer_test.cpp

示例11: close

bool ThreadPool::close()
{
		/*关闭线程池*/
		std::lock_guard<std::mutex> lck(mtx);
		running=false;
		cond_var.notify_all();
		for(auto thread:threadPool)
		{
				thread->join();
				delete thread;
		}
}
开发者ID:riccoqu,项目名称:Paradise-BackUp,代码行数:12,代码来源:threadpool.cpp

示例12: on_run

 // "run"コマンドのイベントリスナ
 void on_run(sio::event& e) {
   std::unique_lock<std::mutex> lock(sio_mutex);
   sio_queue.push(e.get_message());
   // イベントをキューに登録し、待っているメインスレッドを起こす
   sio_cond.notify_all();
 }
开发者ID:llamerada-jp,项目名称:socket.io-cpp-client-sample,代码行数:7,代码来源:client.cpp


注:本文中的std::condition_variable_any::notify_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。