event/SocketMonitor: un-inline Schedule()
Merge with CommitEventFlags().
This commit is contained in:
parent
0287ac794e
commit
b63db1c1aa
@ -135,6 +135,20 @@ SocketMonitor::Close()
|
|||||||
close_socket(Steal());
|
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::ssize_t
|
||||||
SocketMonitor::Read(void *data, size_t length)
|
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);
|
return send(Get(), (const char *)data, length, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
|
||||||
SocketMonitor::CommitEventFlags()
|
|
||||||
{
|
|
||||||
assert(IsDefined());
|
|
||||||
|
|
||||||
loop.WakeUp();
|
|
||||||
}
|
|
||||||
|
@ -86,37 +86,32 @@ public:
|
|||||||
|
|
||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
void Schedule(unsigned flags) {
|
unsigned GetScheduledFlags() const {
|
||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
poll.events = flags;
|
return poll.events;
|
||||||
poll.revents &= flags;
|
|
||||||
CommitEventFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Schedule(unsigned flags);
|
||||||
|
|
||||||
void Cancel() {
|
void Cancel() {
|
||||||
poll.events = 0;
|
Schedule(0);
|
||||||
CommitEventFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleRead() {
|
void ScheduleRead() {
|
||||||
poll.events |= READ|HANGUP|ERROR;
|
Schedule(GetScheduledFlags() | READ | HANGUP | ERROR);
|
||||||
CommitEventFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduleWrite() {
|
void ScheduleWrite() {
|
||||||
poll.events |= WRITE;
|
Schedule(GetScheduledFlags() | WRITE);
|
||||||
CommitEventFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancelRead() {
|
void CancelRead() {
|
||||||
poll.events &= ~(READ|HANGUP|ERROR);
|
Schedule(GetScheduledFlags() & ~(READ|HANGUP|ERROR));
|
||||||
CommitEventFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancelWrite() {
|
void CancelWrite() {
|
||||||
poll.events &= ~WRITE;
|
Schedule(GetScheduledFlags() & ~WRITE);
|
||||||
CommitEventFlags();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ssize_t Read(void *data, size_t length);
|
ssize_t Read(void *data, size_t length);
|
||||||
@ -136,8 +131,6 @@ public:
|
|||||||
gpointer user_data);
|
gpointer user_data);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void CommitEventFlags();
|
|
||||||
|
|
||||||
bool Check() const {
|
bool Check() const {
|
||||||
assert(IsDefined());
|
assert(IsDefined());
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user