CMS 3D CMS Logo

SonicDispatcherPseudoAsync.cc
Go to the documentation of this file.
4 
6  : SonicDispatcher(client), hasCall_(false), stop_(false) {
7  thread_ = std::make_unique<std::thread>([this]() { waitForNext(); });
8 }
9 
11  stop_ = true;
12  cond_.notify_one();
13  if (thread_) {
14  // avoid throwing in destructor
15  CMS_SA_ALLOW try {
16  thread_->join();
17  thread_.reset();
18  } catch (...) {
19  }
20  }
21 }
22 
24  //do all read/writes inside lock to ensure cache synchronization
25  {
26  std::lock_guard<std::mutex> guard(mutex_);
27  client_->start(std::move(holder));
28 
29  //activate thread to wait for response, and return
30  hasCall_ = true;
31  }
32  cond_.notify_one();
33 }
34 
36  while (true) {
37  //wait for condition
38  {
39  std::unique_lock<std::mutex> lk(mutex_);
40  cond_.wait(lk, [this]() { return (hasCall_ or stop_); });
41  if (stop_)
42  break;
43 
44  //do everything inside lock
45  client_->evaluate();
46 
47  //reset condition
48  hasCall_ = false;
49  }
50  }
51 }
#define CMS_SA_ALLOW
virtual void evaluate()=0
std::unique_ptr< std::thread > thread_
void start(edm::WaitingTaskWithArenaHolder holder)
SonicDispatcherPseudoAsync(SonicClientBase *client)
virtual void dispatch()
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
def move(src, dest)
Definition: eostools.py:511
SonicClientBase * client_