2 #ifndef CommonEventLoop_H_
3 #define CommonEventLoop_H_
9 #include <condition_variable>
24 virtual void evprepare(
const ev::loop_ref& ) {}
28 virtual void evfinish(
const ev::loop_ref& ) {}
30 virtual std::string wname()
const noexcept
59 bool evIsActive()
const noexcept;
68 bool evrun(
EvWatcher* w,
bool thread =
true,
size_t waitPrepareTimeout_msec = 8000);
73 inline const ev::loop_ref evloop() noexcept
85 void onStop( ev::async& w,
int revents ) noexcept;
86 void onPrepare( ev::async& w,
int revents ) noexcept;
87 void defaultLoop() noexcept;
89 std::atomic_bool cancelled = {
false };
90 std::atomic_bool isrunning = {
false };
92 ev::dynamic_loop loop;
94 std::shared_ptr<std::thread> thr;
97 std::mutex term_mutex;
98 std::condition_variable term_event;
99 std::atomic_bool term_notify = {
false };
101 std::mutex wlist_mutex;
102 std::vector<EvWatcher*> wlist;
108 std::condition_variable prep_event;
109 std::mutex prep_mutex;
110 std::atomic_bool prep_notify = {
false };
115 #endif // CommonEventLoop_H_