Commit b082bfb4 authored by knowledge4igor's avatar knowledge4igor

Tiny code improvements

parent c5fd213e
......@@ -18,7 +18,7 @@
namespace Pistache {
typedef int Fd;
using Fd = int;
uint hardware_concurrency();
bool make_non_blocking(int fd);
......@@ -87,8 +87,10 @@ inline constexpr bool operator==(Tag lhs, Tag rhs) {
}
struct Event {
explicit Event(Tag _tag) :
tag(_tag)
explicit Event(Tag _tag)
: flags()
, fd(-1)
, tag(_tag)
{ }
Flags<NotifyOn> flags;
......@@ -111,8 +113,8 @@ public:
std::chrono::milliseconds timeout = std::chrono::milliseconds(0)) const;
private:
int toEpollEvents(Flags<NotifyOn> interest) const;
Flags<NotifyOn> toNotifyOn(int events) const;
static int toEpollEvents(const Flags<NotifyOn>& interest);
static Flags<NotifyOn> toNotifyOn(int events);
int epoll_fd;
};
......
......@@ -25,13 +25,13 @@ uint hardware_concurrency() {
}
bool make_non_blocking(int sfd)
bool make_non_blocking(int fd)
{
int flags = fcntl (sfd, F_GETFL, 0);
int flags = fcntl (fd, F_GETFL, 0);
if (flags == -1) return false;
flags |= O_NONBLOCK;
int ret = fcntl (sfd, F_SETFL, flags);
int ret = fcntl (fd, F_SETFL, flags);
if (ret == -1) return false;
return true;
......@@ -206,7 +206,7 @@ namespace Polling {
}
int
Epoll::toEpollEvents(Flags<NotifyOn> interest) const {
Epoll::toEpollEvents(const Flags<NotifyOn>& interest) {
int events = 0;
if (interest.hasFlag(NotifyOn::Read))
......@@ -222,7 +222,7 @@ namespace Polling {
}
Flags<NotifyOn>
Epoll::toNotifyOn(int events) const {
Epoll::toNotifyOn(int events) {
Flags<NotifyOn> flags;
if (events & EPOLLIN)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment