File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change @@ -116,6 +116,30 @@ void AsioEvent::Wait(boost::asio::yield_context yc)
116
116
m_Timer.async_wait (yc[ec]);
117
117
}
118
118
119
+ AsioConditionVariable::AsioConditionVariable (boost::asio::io_context& io)
120
+ : m_Timer(io)
121
+ {
122
+ m_Timer.expires_at (boost::posix_time::pos_infin);
123
+ }
124
+
125
+ void AsioConditionVariable::Wait (boost::asio::yield_context yc)
126
+ {
127
+ boost::system ::error_code ec;
128
+ m_Timer.async_wait (yc[ec]);
129
+ }
130
+
131
+ bool AsioConditionVariable::NotifyOne ()
132
+ {
133
+ boost::system ::error_code ec;
134
+ return m_Timer.cancel_one (ec);
135
+ }
136
+
137
+ size_t AsioConditionVariable::NotifyAll ()
138
+ {
139
+ boost::system ::error_code ec;
140
+ return m_Timer.cancel (ec);
141
+ }
142
+
119
143
/* *
120
144
* Cancels any pending timeout callback.
121
145
*
Original file line number Diff line number Diff line change @@ -55,6 +55,24 @@ class CpuBoundWork
55
55
bool m_Done;
56
56
};
57
57
58
+ /* *
59
+ * Condition variable which doesn't block I/O threads
60
+ *
61
+ * @ingroup base
62
+ */
63
+ class AsioConditionVariable
64
+ {
65
+ public:
66
+ AsioConditionVariable (boost::asio::io_context& io);
67
+
68
+ void Wait (boost::asio::yield_context yc);
69
+ bool NotifyOne ();
70
+ size_t NotifyAll ();
71
+
72
+ private:
73
+ boost::asio::deadline_timer m_Timer;
74
+ };
75
+
58
76
/* *
59
77
* Async I/O engine
60
78
*
You can’t perform that action at this time.
0 commit comments