summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kqueue.cpp25
1 files changed, 17 insertions, 8 deletions
diff --git a/src/kqueue.cpp b/src/kqueue.cpp
index bb42d8f..cbf38d1 100644
--- a/src/kqueue.cpp
+++ b/src/kqueue.cpp
@@ -33,6 +33,7 @@
#include "err.hpp"
#include "config.hpp"
#include "i_poll_events.hpp"
+#include "likely.hpp"
// NetBSD defines (struct kevent).udata as intptr_t, everyone else
// as void *.
@@ -106,29 +107,37 @@ void zmq::kqueue_t::rm_fd (handle_t handle_)
void zmq::kqueue_t::set_pollin (handle_t handle_)
{
poll_entry_t *pe = (poll_entry_t*) handle_;
- pe->flag_pollin = true;
- kevent_add (pe->fd, EVFILT_READ, pe);
+ if (likely (!pe->flag_pollin)) {
+ pe->flag_pollin = true;
+ kevent_add (pe->fd, EVFILT_READ, pe);
+ }
}
void zmq::kqueue_t::reset_pollin (handle_t handle_)
{
poll_entry_t *pe = (poll_entry_t*) handle_;
- pe->flag_pollin = false;
- kevent_delete (pe->fd, EVFILT_READ);
+ if (likely (pe->flag_pollin)) {
+ pe->flag_pollin = false;
+ kevent_delete (pe->fd, EVFILT_READ);
+ }
}
void zmq::kqueue_t::set_pollout (handle_t handle_)
{
poll_entry_t *pe = (poll_entry_t*) handle_;
- pe->flag_pollout = true;
- kevent_add (pe->fd, EVFILT_WRITE, pe);
+ if (likely (!pe->flag_pollout)) {
+ pe->flag_pollout = true;
+ kevent_add (pe->fd, EVFILT_WRITE, pe);
+ }
}
void zmq::kqueue_t::reset_pollout (handle_t handle_)
{
poll_entry_t *pe = (poll_entry_t*) handle_;
- pe->flag_pollout = false;
- kevent_delete (pe->fd, EVFILT_WRITE);
+ if (likely (pe->flag_pollout)) {
+ pe->flag_pollout = false;
+ kevent_delete (pe->fd, EVFILT_WRITE);
+ }
}
void zmq::kqueue_t::start ()