20 #ifndef MPD_EVENT_LOOP_HXX
21 #define MPD_EVENT_LOOP_HXX
58 const std::chrono::steady_clock::time_point due;
63 std::chrono::steady_clock::time_point _due)
64 :due(_due), timer(_timer) {}
66 bool operator<(
const TimerRecord &other)
const {
67 return due < other.due;
70 bool IsDue(std::chrono::steady_clock::time_point _now)
const {
77 std::multiset<TimerRecord> timers;
78 std::list<IdleMonitor *> idle;
81 std::list<DeferredMonitor *> deferred;
83 std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now();
109 PollGroup poll_group;
110 PollResult poll_result;
124 std::chrono::steady_clock::time_point
GetTime()
const {
140 return poll_group.Add(_fd, flags, &m);
146 return poll_group.Modify(_fd, flags, &m);
162 std::chrono::steady_clock::duration d);
192 void HandleDeferred();
194 virtual bool OnSocketReady(
unsigned flags)
override;
gcc_pure bool IsInsideOrVirgin() const
This class monitors a timeout.
An event that runs when the EventLoop has become idle, before waiting for more events.
A low-level identification for a thread.
void CancelTimer(TimeoutMonitor &t)
An event loop that polls for events on file/socket descriptors.
void Break()
Stop execution of this EventLoop at the next chance.
void AddIdle(IdleMonitor &i)
void RemoveIdle(IdleMonitor &i)
Defer execution of an event into an EventLoop.
gcc_pure bool IsInside() const
Are we currently running inside this EventLoop's thread?
bool AddFD(int _fd, unsigned flags, SocketMonitor &m)
void Abandon()
Somebody has closed the socket.
gcc_pure bool IsInsideOrNull() const
Like IsInside(), but also returns true if the thread has already ended (or was not started yet)...
void Run()
The main function of this class.
std::chrono::steady_clock::time_point GetTime() const
A caching wrapper for std::chrono::steady_clock::now().
Monitor events on a socket.
void AddTimer(TimeoutMonitor &t, std::chrono::steady_clock::duration d)
bool IsInside() const
Check if this thread is the current thread.
static gcc_const ThreadId Null()
void AddDeferred(DeferredMonitor &d)
Schedule a call to DeferredMonitor::RunDeferred().
bool RemoveFD(int fd, SocketMonitor &m)
bool ModifyFD(int _fd, unsigned flags, SocketMonitor &m)
gcc_pure bool IsNull() const
void RemoveDeferred(DeferredMonitor &d)
Cancel a pending call to DeferredMonitor::RunDeferred().