From b63db1c1aa220cf9866f6b8b01b62f16e15c58a1 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 7 Aug 2013 23:57:30 +0200 Subject: event/SocketMonitor: un-inline Schedule() Merge with CommitEventFlags(). --- src/event/SocketMonitor.cxx | 22 ++++++++++++++-------- src/event/SocketMonitor.hxx | 25 +++++++++---------------- 2 files changed, 23 insertions(+), 24 deletions(-) (limited to 'src') diff --git a/src/event/SocketMonitor.cxx b/src/event/SocketMonitor.cxx index 9bb6e47cf..0b929dd72 100644 --- a/src/event/SocketMonitor.cxx +++ b/src/event/SocketMonitor.cxx @@ -135,6 +135,20 @@ SocketMonitor::Close() close_socket(Steal()); } +void +SocketMonitor::Schedule(unsigned flags) +{ + assert(IsDefined()); + + if (flags == GetScheduledFlags()) + return; + + poll.events = flags; + poll.revents &= flags; + + loop.WakeUp(); +} + SocketMonitor::ssize_t SocketMonitor::Read(void *data, size_t length) { @@ -163,11 +177,3 @@ SocketMonitor::Write(const void *data, size_t length) return send(Get(), (const char *)data, length, flags); } - -void -SocketMonitor::CommitEventFlags() -{ - assert(IsDefined()); - - loop.WakeUp(); -} diff --git a/src/event/SocketMonitor.hxx b/src/event/SocketMonitor.hxx index 4cd214018..1abeb82ca 100644 --- a/src/event/SocketMonitor.hxx +++ b/src/event/SocketMonitor.hxx @@ -86,37 +86,32 @@ public: void Close(); - void Schedule(unsigned flags) { + unsigned GetScheduledFlags() const { assert(IsDefined()); - poll.events = flags; - poll.revents &= flags; - CommitEventFlags(); + return poll.events; } + void Schedule(unsigned flags); + void Cancel() { - poll.events = 0; - CommitEventFlags(); + Schedule(0); } void ScheduleRead() { - poll.events |= READ|HANGUP|ERROR; - CommitEventFlags(); + Schedule(GetScheduledFlags() | READ | HANGUP | ERROR); } void ScheduleWrite() { - poll.events |= WRITE; - CommitEventFlags(); + Schedule(GetScheduledFlags() | WRITE); } void CancelRead() { - poll.events &= ~(READ|HANGUP|ERROR); - CommitEventFlags(); + Schedule(GetScheduledFlags() & ~(READ|HANGUP|ERROR)); } void CancelWrite() { - poll.events &= ~WRITE; - CommitEventFlags(); + Schedule(GetScheduledFlags() & ~WRITE); } ssize_t Read(void *data, size_t length); @@ -136,8 +131,6 @@ public: gpointer user_data); private: - void CommitEventFlags(); - bool Check() const { assert(IsDefined()); -- cgit v1.2.3