Sketch the missing driver API functions and avoid virtual function calls.
The individual interface getters are now overridden in the final sub classes to avoid virtual calls whenever the final type is used.
This commit is contained in:
parent
b1663cc472
commit
3868ee64ce
|
@ -12,6 +12,7 @@ interface EventDriver {
|
||||||
@property EventDriverSockets sockets();
|
@property EventDriverSockets sockets();
|
||||||
@property EventDriverTimers udp();
|
@property EventDriverTimers udp();
|
||||||
@property EventDriverEvents events();
|
@property EventDriverEvents events();
|
||||||
|
@property EventDriverSignals signals();
|
||||||
@property EventDriverWatchers watchers();
|
@property EventDriverWatchers watchers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,6 +144,12 @@ interface EventDriverEvents {
|
||||||
void cancelWaitForEvent(EventID event, EventCallback on_event);
|
void cancelWaitForEvent(EventID event, EventCallback on_event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface EventDriverSignals {
|
||||||
|
@safe: /*@nogc:*/ nothrow:
|
||||||
|
//void waitForSignal(int sig, SignalCallback on_signal);
|
||||||
|
//void cancelWaitForSignal(sig);
|
||||||
|
}
|
||||||
|
|
||||||
interface EventDriverTimers {
|
interface EventDriverTimers {
|
||||||
@safe: /*@nogc:*/ nothrow:
|
@safe: /*@nogc:*/ nothrow:
|
||||||
/**
|
/**
|
||||||
|
@ -168,7 +175,9 @@ interface EventDriverTimers {
|
||||||
|
|
||||||
interface EventDriverWatchers {
|
interface EventDriverWatchers {
|
||||||
@safe: /*@nogc:*/ nothrow:
|
@safe: /*@nogc:*/ nothrow:
|
||||||
|
//WatcherID watchDirectory(Path path, bool recursive);
|
||||||
|
//void waitForChanges(WatcherID watcher, FileChangesCallback callback);
|
||||||
|
//void cancelWaitForChanges(WatcherID watcher);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -29,6 +29,16 @@ final class EpollEventDriver : PosixEventDriver {
|
||||||
m_events.length = 100;
|
m_events.length = 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
nothrow @safe {
|
||||||
|
override @property EpollEventDriver core() { return this; }
|
||||||
|
override @property EpollEventDriver files() { return this; }
|
||||||
|
override @property EpollEventDriver sockets() { return this; }
|
||||||
|
override @property EpollEventDriver udp() { return this; }
|
||||||
|
override @property EpollEventDriver events() { return this; }
|
||||||
|
override @property EpollEventDriver signals() { return this; }
|
||||||
|
override @property EpollEventDriver watchers() { return this; }
|
||||||
|
}
|
||||||
|
|
||||||
override bool doProcessEvents(Duration timeout)
|
override bool doProcessEvents(Duration timeout)
|
||||||
@trusted {
|
@trusted {
|
||||||
import std.algorithm : min;
|
import std.algorithm : min;
|
||||||
|
|
|
@ -36,7 +36,10 @@ private long currStdTime()
|
||||||
return Clock.currStdTime;
|
return Clock.currStdTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract class PosixEventDriver : EventDriver, EventDriverCore, EventDriverFiles, EventDriverSockets, EventDriverTimers, EventDriverEvents, EventDriverWatchers {
|
abstract class PosixEventDriver : EventDriver,
|
||||||
|
EventDriverCore, EventDriverFiles, EventDriverSockets, EventDriverTimers,
|
||||||
|
EventDriverEvents, EventDriverSignals, EventDriverWatchers
|
||||||
|
{
|
||||||
@safe: /*@nogc:*/ nothrow:
|
@safe: /*@nogc:*/ nothrow:
|
||||||
|
|
||||||
private {
|
private {
|
||||||
|
@ -54,12 +57,14 @@ abstract class PosixEventDriver : EventDriver, EventDriverCore, EventDriverFiles
|
||||||
//startNotify!(EventType.read)(m_wakeupEvent, null); // should already be caught by registerFD
|
//startNotify!(EventType.read)(m_wakeupEvent, null); // should already be caught by registerFD
|
||||||
}
|
}
|
||||||
|
|
||||||
@property PosixEventDriver core() { return this; }
|
// force overriding these in the (final) sub classes to avoid virtual calls
|
||||||
@property PosixEventDriver files() { return this; }
|
abstract override @property PosixEventDriver core();
|
||||||
@property PosixEventDriver sockets() { return this; }
|
abstract override @property PosixEventDriver files();
|
||||||
@property PosixEventDriver udp() { return this; }
|
abstract override @property PosixEventDriver sockets();
|
||||||
@property PosixEventDriver events() { return this; }
|
abstract override @property PosixEventDriver udp();
|
||||||
@property PosixEventDriver watchers() { return this; }
|
abstract override @property PosixEventDriver events();
|
||||||
|
abstract override @property PosixEventDriver signals();
|
||||||
|
abstract override @property PosixEventDriver watchers();
|
||||||
|
|
||||||
mixin DefaultTimerImpl!();
|
mixin DefaultTimerImpl!();
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,14 @@ version (Windows) {
|
||||||
|
|
||||||
|
|
||||||
final class SelectEventDriver : PosixEventDriver {
|
final class SelectEventDriver : PosixEventDriver {
|
||||||
|
override @property SelectEventDriver core() { return this; }
|
||||||
|
override @property SelectEventDriver files() { return this; }
|
||||||
|
override @property SelectEventDriver sockets() { return this; }
|
||||||
|
override @property SelectEventDriver udp() { return this; }
|
||||||
|
override @property SelectEventDriver events() { return this; }
|
||||||
|
override @property SelectEventDriver signals() { return this; }
|
||||||
|
override @property SelectEventDriver watchers() { return this; }
|
||||||
|
|
||||||
override bool doProcessEvents(Duration timeout)
|
override bool doProcessEvents(Duration timeout)
|
||||||
{
|
{
|
||||||
//assert(Fiber.getThis() is null, "processEvents may not be called from within a fiber!");
|
//assert(Fiber.getThis() is null, "processEvents may not be called from within a fiber!");
|
||||||
|
|
Loading…
Reference in a new issue