diff --git a/muduo/net/Channel.cc b/muduo/net/Channel.cc index 1e9a40ae7..e5ffce30d 100644 --- a/muduo/net/Channel.cc +++ b/muduo/net/Channel.cc @@ -12,15 +12,9 @@ #include -#include - using namespace muduo; using namespace muduo::net; -const int Channel::kNoneEvent = 0; -const int Channel::kReadEvent = POLLIN | POLLPRI; -const int Channel::kWriteEvent = POLLOUT; - Channel::Channel(EventLoop* loop, int fd__) : loop_(loop), fd_(fd__), diff --git a/muduo/net/Channel.h b/muduo/net/Channel.h index bafa224fa..945ceebdd 100644 --- a/muduo/net/Channel.h +++ b/muduo/net/Channel.h @@ -16,6 +16,7 @@ #include #include +#include namespace muduo { @@ -86,9 +87,9 @@ class Channel : noncopyable void update(); void handleEventWithGuard(Timestamp receiveTime); - static const int kNoneEvent; - static const int kReadEvent; - static const int kWriteEvent; + static constexpr int kNoneEvent = 0; + static constexpr int kReadEvent = POLLIN | POLLPRI; + static constexpr int kWriteEvent = POLLOUT; EventLoop* loop_; const int fd_;