Skip to content

Commit

Permalink
selector/kqueue: improve speed
Browse files Browse the repository at this point in the history
  • Loading branch information
meh committed Jul 25, 2012
1 parent 2edd19b commit 2f735a7
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions nucular/selector/kqueue.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ module nucular.selector.kqueue;

version (kqueue):

import std.stdio : writeln;

import core.time;
import core.stdc.errno;
import core.sys.freebsd.sys.event;
Expand Down Expand Up @@ -166,16 +164,20 @@ class Selector : base.Selector
EV_SET(&ev, descriptor.to!int, 0, 0, 0, 0, cast (void*) index);

static if (mode == "read") {
ev.filter = EVFILT_WRITE;
ev.flags = EV_ADD | EV_DISABLE;
if (_last == "both") {
ev.filter = EVFILT_WRITE;
ev.flags = EV_ADD | EV_DISABLE;

errnoEnforce(.kevent(_kq, &ev, 1, null, 0, null) >= 0);
errnoEnforce(.kevent(_kq, &ev, 1, null, 0, null) >= 0);
}
}
else static if (mode == "write") {
ev.filter = EVFILT_READ;
ev.flags = EV_ADD | EV_DISABLE;
if (_last == "both") {
ev.filter = EVFILT_READ;
ev.flags = EV_ADD | EV_DISABLE;

errnoEnforce(.kevent(_kq, &ev, 1, null, 0, null) >= 0);
errnoEnforce(.kevent(_kq, &ev, 1, null, 0, null) >= 0);
}
}

static if (mode == "read" || mode == "both") {
Expand Down

0 comments on commit 2f735a7

Please sign in to comment.