event/SocketMonitor: add assertions
This commit is contained in:
parent
0005221533
commit
0287ac794e
@ -138,6 +138,8 @@ SocketMonitor::Close()
|
|||||||
SocketMonitor::ssize_t
|
SocketMonitor::ssize_t
|
||||||
SocketMonitor::Read(void *data, size_t length)
|
SocketMonitor::Read(void *data, size_t length)
|
||||||
{
|
{
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#ifdef MSG_DONTWAIT
|
#ifdef MSG_DONTWAIT
|
||||||
flags |= MSG_DONTWAIT;
|
flags |= MSG_DONTWAIT;
|
||||||
@ -149,6 +151,8 @@ SocketMonitor::Read(void *data, size_t length)
|
|||||||
SocketMonitor::ssize_t
|
SocketMonitor::ssize_t
|
||||||
SocketMonitor::Write(const void *data, size_t length)
|
SocketMonitor::Write(const void *data, size_t length)
|
||||||
{
|
{
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
int flags = 0;
|
int flags = 0;
|
||||||
#ifdef MSG_NOSIGNAL
|
#ifdef MSG_NOSIGNAL
|
||||||
flags |= MSG_NOSIGNAL;
|
flags |= MSG_NOSIGNAL;
|
||||||
@ -163,5 +167,7 @@ SocketMonitor::Write(const void *data, size_t length)
|
|||||||
void
|
void
|
||||||
SocketMonitor::CommitEventFlags()
|
SocketMonitor::CommitEventFlags()
|
||||||
{
|
{
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
loop.WakeUp();
|
loop.WakeUp();
|
||||||
}
|
}
|
||||||
|
@ -87,6 +87,8 @@ public:
|
|||||||
void Close();
|
void Close();
|
||||||
|
|
||||||
void Schedule(unsigned flags) {
|
void Schedule(unsigned flags) {
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
poll.events = flags;
|
poll.events = flags;
|
||||||
poll.revents &= flags;
|
poll.revents &= flags;
|
||||||
CommitEventFlags();
|
CommitEventFlags();
|
||||||
@ -137,10 +139,14 @@ private:
|
|||||||
void CommitEventFlags();
|
void CommitEventFlags();
|
||||||
|
|
||||||
bool Check() const {
|
bool Check() const {
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
return (poll.revents & poll.events) != 0;
|
return (poll.revents & poll.events) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Dispatch() {
|
void Dispatch() {
|
||||||
|
assert(IsDefined());
|
||||||
|
|
||||||
OnSocketReady(poll.revents & poll.events);
|
OnSocketReady(poll.revents & poll.events);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user