From: Davin McCall Date: Sun, 5 Jun 2016 09:31:00 +0000 (+0100) Subject: Make selection of epoll/kqueue backend automatic X-Git-Tag: v0.01~14 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=5f57306f3a91f11ebb4e96e89234245c763ef352;p=oweals%2Fdinit.git Make selection of epoll/kqueue backend automatic --- diff --git a/src/dasync/dasync.h b/src/dasync/dasync.h index e3e8b51..b43cf09 100644 --- a/src/dasync/dasync.h +++ b/src/dasync/dasync.h @@ -11,10 +11,17 @@ #if defined(HAVE_KQUEUE) #include "dasync-kqueue.h" +namespace dasync { + template using Loop = KqueueLoop; + using LoopTraits = KqueueTraits; +} #elif defined(HAVE_EPOLL) #include "dasync-epoll.h" +namespace dasync { + template using Loop = EpollLoop; + using LoopTraits = EpollTraits; +} #endif - #include #include #include @@ -71,7 +78,7 @@ template class PosixChildWatcher; // Information about a received signal. // This is essentially a wrapper for the POSIX siginfo_t; its existence allows for mechanisms that receive // equivalent signal information in a different format (eg signalfd on Linux). -using SigInfo = EpollTraits::SigInfo; +using SigInfo = LoopTraits::SigInfo; namespace dprivate { // (non-public API) @@ -409,7 +416,7 @@ template class EventLoop using BaseChildWatcher = dprivate::BaseChildWatcher; using WatchType = dprivate::WatchType; - EpollLoop>> loop_mech; + Loop>> loop_mech; // There is a complex problem with most asynchronous event notification mechanisms // when used in a multi-threaded environment. Generally, a file descriptor or other @@ -472,7 +479,7 @@ template class EventLoop waitqueue_node qnode; getAttnLock(qnode); - EventDispatch & ed = (EventDispatch &) loop_mech; + EventDispatch & ed = (EventDispatch &) loop_mech; ed.issueDelete(callBack); releaseLock(qnode); @@ -490,7 +497,7 @@ template class EventLoop waitqueue_node qnode; getAttnLock(qnode); - EventDispatch & ed = (EventDispatch &) loop_mech; + EventDispatch & ed = (EventDispatch &) loop_mech; ed.issueDelete(callback); releaseLock(qnode); @@ -641,7 +648,7 @@ template class EventLoop bool processEvents() noexcept { - EventDispatch & ed = (EventDispatch &) loop_mech; + EventDispatch & ed = (EventDispatch &) loop_mech; ed.lock.lock(); // So this pulls *all* currently pending events and processes them in the current thread.