Commit d2a4f64f authored by Max Kellermann's avatar Max Kellermann

event/BlockingCall: always use DeferredMonitor internally

There is no advantage of using EventLoop::AddCall(), now that DeferredMonitor is thread-safe.
parent a357d84d
......@@ -28,9 +28,7 @@
#include <assert.h>
class BlockingCallMonitor final
#ifdef USE_GLIB_EVENTLOOP
: DeferredMonitor
#endif
{
const std::function<void()> f;
......@@ -40,26 +38,13 @@ class BlockingCallMonitor final
bool done;
public:
#ifdef USE_INTERNAL_EVENTLOOP
BlockingCallMonitor(EventLoop &loop, std::function<void()> &&_f)
:f(std::move(_f)), done(false) {
loop.AddCall([this](){
this->DoRun();
});
}
#endif
#ifdef USE_GLIB_EVENTLOOP
BlockingCallMonitor(EventLoop &_loop, std::function<void()> &&_f)
:DeferredMonitor(_loop), f(std::move(_f)), done(false) {}
#endif
void Run() {
#ifdef USE_GLIB_EVENTLOOP
assert(!done);
Schedule();
#endif
mutex.lock();
while (!done)
......@@ -67,17 +52,8 @@ public:
mutex.unlock();
}
#ifdef USE_GLIB_EVENTLOOP
private:
virtual void RunDeferred() override {
DoRun();
}
#endif
#ifdef USE_INTERNAL_EVENTLOOP
public:
#endif
void DoRun() {
assert(!done);
f();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment