event/Call: migrate from DeferredMonitor to DeferEvent
This commit is contained in:
parent
390e830994
commit
bf3ced6a34
@ -20,7 +20,7 @@
|
|||||||
#include "config.h"
|
#include "config.h"
|
||||||
#include "Call.hxx"
|
#include "Call.hxx"
|
||||||
#include "Loop.hxx"
|
#include "Loop.hxx"
|
||||||
#include "DeferredMonitor.hxx"
|
#include "DeferEvent.hxx"
|
||||||
#include "thread/Mutex.hxx"
|
#include "thread/Mutex.hxx"
|
||||||
#include "thread/Cond.hxx"
|
#include "thread/Cond.hxx"
|
||||||
#include "Compiler.h"
|
#include "Compiler.h"
|
||||||
@ -30,8 +30,9 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
|
|
||||||
class BlockingCallMonitor final
|
class BlockingCallMonitor final
|
||||||
: DeferredMonitor
|
|
||||||
{
|
{
|
||||||
|
DeferEvent defer_event;
|
||||||
|
|
||||||
const std::function<void()> f;
|
const std::function<void()> f;
|
||||||
|
|
||||||
Mutex mutex;
|
Mutex mutex;
|
||||||
@ -43,12 +44,13 @@ class BlockingCallMonitor final
|
|||||||
|
|
||||||
public:
|
public:
|
||||||
BlockingCallMonitor(EventLoop &_loop, std::function<void()> &&_f)
|
BlockingCallMonitor(EventLoop &_loop, std::function<void()> &&_f)
|
||||||
:DeferredMonitor(_loop), f(std::move(_f)), done(false) {}
|
:defer_event(_loop, BIND_THIS_METHOD(RunDeferred)),
|
||||||
|
f(std::move(_f)), done(false) {}
|
||||||
|
|
||||||
void Run() {
|
void Run() {
|
||||||
assert(!done);
|
assert(!done);
|
||||||
|
|
||||||
Schedule();
|
defer_event.Schedule();
|
||||||
|
|
||||||
mutex.lock();
|
mutex.lock();
|
||||||
while (!done)
|
while (!done)
|
||||||
@ -60,7 +62,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual void RunDeferred() override {
|
void RunDeferred() noexcept {
|
||||||
assert(!done);
|
assert(!done);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
Loading…
Reference in New Issue
Block a user