Example #1
0
void fut_wait(){
  thread::id tid = this_thread::get_id();
  while(fut.valid()){
    fut.wait();
    bool ret = fut.get();
    COUT << tid << " ret:" << ret << endl;
  }
}
Example #2
0
void t_future(){
  //NOTICE("fut.get");
  //fut.get();

  NOTICE("fut.wait");
  fut.wait();

  thread t1(fut_wait), t2(fut_wait), t3(fut_wait);
  while(true){
    prom = promise<bool>();
    fut = prom.get_future();
    sleep(2);
    prom.set_value(false);
    sleep(3);
  }
  t1.join();
  t2.join();
  t3.join();
}