From 4b1afa8d6c444e5b54a8d43c137a6a819b37fb42 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6nke=20Ludwig?= Date: Tue, 19 May 2020 22:52:44 +0200 Subject: [PATCH] Allow to inherit from the kqueue loop implementation. --- source/eventcore/drivers/posix/loop/kqueue.d | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/source/eventcore/drivers/posix/loop/kqueue.d b/source/eventcore/drivers/posix/loop/kqueue.d index 14aa2a3..4a0c8ad 100644 --- a/source/eventcore/drivers/posix/loop/kqueue.d +++ b/source/eventcore/drivers/posix/loop/kqueue.d @@ -31,8 +31,16 @@ import core.sys.linux.epoll; alias KqueueEventDriver = PosixEventDriver!KqueueEventLoop; -final class KqueueEventLoop : PosixEventLoop { - private { +final class KqueueEventLoop : KqueueEventLoopBase { + override bool doProcessEvents(Duration timeout) + @trusted { + return doProcessEventsBase(timeout); + } +} + + +abstract class KqueueEventLoopBase : PosixEventLoop { + protected { int m_queue; size_t m_changeCount = 0; kevent_t[100] m_changes; @@ -45,8 +53,8 @@ final class KqueueEventLoop : PosixEventLoop { assert(m_queue >= 0, "Failed to create kqueue."); } - override bool doProcessEvents(Duration timeout) - @trusted { + protected bool doProcessEventsBase(Duration timeout) + @trusted nothrow { import std.algorithm : min; //assert(Fiber.getThis() is null, "processEvents may not be called from within a fiber!");