CMS 3D CMS Logo

SonicDispatcherPseudoAsync.h
Go to the documentation of this file.
1 #ifndef HeterogeneousCore_SonicCore_SonicDispatcherPseudoAsync
2 #define HeterogeneousCore_SonicCore_SonicDispatcherPseudoAsync
3 
5 
6 #include <memory>
7 #include <condition_variable>
8 #include <mutex>
9 #include <thread>
10 #include <atomic>
11 #include <exception>
12 
13 class SonicClientBase;
14 
15 //pretend to be async + non-blocking by waiting for blocking calls to return in separate std::thread
17 public:
18  //constructor
20 
21  //destructor
22  ~SonicDispatcherPseudoAsync() override;
23 
24  //main operation
25  void dispatch(edm::WaitingTaskWithArenaHolder holder) override;
26 
27 private:
28  void waitForNext();
29 
30  //members
31  bool hasCall_;
33  std::condition_variable cond_;
34  std::atomic<bool> stop_;
35  std::unique_ptr<std::thread> thread_;
36 };
37 
38 #endif
std::unique_ptr< std::thread > thread_
static std::mutex mutex
Definition: Proxy.cc:8
SonicDispatcherPseudoAsync(SonicClientBase *client)
virtual void dispatch()