event/DeferredMonitor: use EventLoop::AddIdle()
This commit is contained in:
@@ -32,7 +32,7 @@ DeferredMonitor::Cancel()
|
||||
void
|
||||
DeferredMonitor::Schedule()
|
||||
{
|
||||
const unsigned id = g_idle_add(Callback, this);
|
||||
const unsigned id = loop.AddIdle(Callback, this);
|
||||
const auto old_id = source_id.exchange(id);
|
||||
if (old_id != 0)
|
||||
g_source_remove(old_id);
|
||||
|
@@ -26,15 +26,19 @@
|
||||
|
||||
#include <atomic>
|
||||
|
||||
class EventLoop;
|
||||
|
||||
/**
|
||||
* Defer execution of an event into an #EventLoop.
|
||||
*/
|
||||
class DeferredMonitor {
|
||||
EventLoop &loop;
|
||||
|
||||
std::atomic<guint> source_id;
|
||||
|
||||
public:
|
||||
DeferredMonitor()
|
||||
:source_id(0) {}
|
||||
DeferredMonitor(EventLoop &_loop)
|
||||
:loop(_loop), source_id(0) {}
|
||||
|
||||
~DeferredMonitor() {
|
||||
Cancel();
|
||||
|
Reference in New Issue
Block a user