Add stub libasync support.

This commit is contained in:
Sönke Ludwig 2016-10-05 14:38:29 +02:00
parent b95c9e5bbc
commit 95ccc347d5
3 changed files with 324 additions and 1 deletions

View file

@ -2,3 +2,12 @@ name "eventcore"
description "Experimental callback based abstraction layer over operating system asynchronous I/O facilities."
license "MIT"
copyright "Copyright © 2012-2016 rejectedsoftware e.K."
targetType "library"
configuration "native" {
}
configuration "libasync" {
dependency "libasync" version="~>0.7.9"
}

View file

@ -3,9 +3,11 @@ module eventcore.core;
public import eventcore.driver;
import eventcore.drivers.epoll;
import eventcore.drivers.libasync;
import eventcore.drivers.select;
alias NativeEventDriver = SelectEventDriver;
version (Have_libasync) alias NativeEventDriver = LibasyncEventDriver;
else alias NativeEventDriver = SelectEventDriver;
@property EventDriver eventDriver()
@safe @nogc nothrow {

View file

@ -0,0 +1,312 @@
module eventcore.drivers.libasync;
version (Have_libasync):
import eventcore.driver;
import std.socket : Address;
import core.time : Duration;
final class LibasyncEventDriver : EventDriver {
@safe: /*@nogc:*/ nothrow:
private {
LibasyncEventDriverCore m_core;
LibasyncEventDriverFiles m_files;
LibasyncEventDriverSockets m_sockets;
LibasyncEventDriverTimers m_timers;
LibasyncEventDriverEvents m_events;
LibasyncEventDriverSignals m_signals;
LibasyncEventDriverWatchers m_watchers;
}
this()
{
m_core = new LibasyncEventDriverCore();
m_files = new LibasyncEventDriverFiles();
m_sockets = new LibasyncEventDriverSockets();
m_timers = new LibasyncEventDriverTimers();
m_events = new LibasyncEventDriverEvents();
m_signals = new LibasyncEventDriverSignals();
m_watchers = new LibasyncEventDriverWatchers();
}
override @property LibasyncEventDriverCore core() { return m_core; }
override @property LibasyncEventDriverFiles files() { return m_files; }
override @property LibasyncEventDriverSockets sockets() { return m_sockets; }
override @property LibasyncEventDriverTimers timers() { return m_timers; }
override @property LibasyncEventDriverEvents events() { return m_events; }
override @property LibasyncEventDriverSignals signals() { return m_signals; }
override @property LibasyncEventDriverWatchers watchers() { return m_watchers; }
}
final class LibasyncEventDriverCore : EventDriverCore {
@safe: /*@nogc:*/ nothrow:
override void dispose()
{
assert(false, "TODO!");
}
override size_t waiterCount()
{
assert(false, "TODO!");
}
override ExitReason processEvents(Duration timeout = Duration.max)
{
assert(false, "TODO!");
}
override void exit()
{
assert(false, "TODO!");
}
override void clearExitFlag()
{
assert(false, "TODO!");
}
protected override void* rawUserData(StreamSocketFD descriptor, size_t size, DataInitializer initialize, DataInitializer destroy) @system
{
assert(false, "TODO!");
}
}
final class LibasyncEventDriverSockets : EventDriverSockets {
@safe: /*@nogc:*/ nothrow:
override StreamSocketFD connectStream(scope Address peer_address, ConnectCallback on_connect)
{
assert(false, "TODO!");
}
override StreamListenSocketFD listenStream(scope Address bind_address, AcceptCallback on_accept)
{
assert(false, "TODO!");
}
override void waitForConnections(StreamListenSocketFD sock, AcceptCallback on_accept)
{
assert(false, "TODO!");
}
override ConnectionState getConnectionState(StreamSocketFD sock)
{
assert(false, "TODO!");
}
override void setTCPNoDelay(StreamSocketFD socket, bool enable)
{
assert(false, "TODO!");
}
override void read(StreamSocketFD socket, ubyte[] buffer, IOMode mode, IOCallback on_read_finish)
{
assert(false, "TODO!");
}
override void write(StreamSocketFD socket, const(ubyte)[] buffer, IOMode mode, IOCallback on_write_finish)
{
assert(false, "TODO!");
}
override void waitForData(StreamSocketFD socket, IOCallback on_data_available)
{
assert(false, "TODO!");
}
override void shutdown(StreamSocketFD socket, bool shut_read = true, bool shut_write = true)
{
assert(false, "TODO!");
}
override void cancelRead(StreamSocketFD socket)
{
assert(false, "TODO!");
}
override void cancelWrite(StreamSocketFD socket)
{
assert(false, "TODO!");
}
override void addRef(SocketFD descriptor)
{
assert(false, "TODO!");
}
override void releaseRef(SocketFD descriptor)
{
assert(false, "TODO!");
}
}
final class LibasyncEventDriverFiles : EventDriverFiles {
@safe: /*@nogc:*/ nothrow:
override FileFD open(string path, FileOpenMode mode)
{
assert(false, "TODO!");
}
override FileFD createTemp()
{
assert(false, "TODO!");
}
override void write(FileFD file, ulong offset, ubyte[] buffer, IOCallback on_write_finish)
{
assert(false, "TODO!");
}
override void read(FileFD file, ulong offset, ubyte[] buffer, IOCallback on_read_finish)
{
assert(false, "TODO!");
}
override void cancelWrite(FileFD file)
{
assert(false, "TODO!");
}
override void cancelRead(FileFD file)
{
assert(false, "TODO!");
}
override void addRef(FileFD descriptor)
{
assert(false, "TODO!");
}
override void releaseRef(FileFD descriptor)
{
assert(false, "TODO!");
}
}
final class LibasyncEventDriverEvents : EventDriverEvents {
@safe: /*@nogc:*/ nothrow:
override EventID create()
{
assert(false, "TODO!");
}
override void trigger(EventID event, bool notify_all = true)
{
assert(false, "TODO!");
}
override void trigger(EventID event, bool notify_all = true) shared
{
assert(false, "TODO!");
}
override void wait(EventID event, EventCallback on_event)
{
assert(false, "TODO!");
}
override void cancelWait(EventID event, EventCallback on_event)
{
assert(false, "TODO!");
}
override void addRef(EventID descriptor)
{
assert(false, "TODO!");
}
override void releaseRef(EventID descriptor)
{
assert(false, "TODO!");
}
}
final class LibasyncEventDriverSignals : EventDriverSignals {
@safe: /*@nogc:*/ nothrow:
override void wait(int sig, SignalCallback on_signal)
{
assert(false, "TODO!");
}
override void cancelWait(int sig)
{
assert(false, "TODO!");
}
}
final class LibasyncEventDriverTimers : EventDriverTimers {
@safe: /*@nogc:*/ nothrow:
override TimerID create()
{
assert(false, "TODO!");
}
override void set(TimerID timer, Duration timeout, Duration repeat = Duration.zero)
{
assert(false, "TODO!");
}
override void stop(TimerID timer)
{
assert(false, "TODO!");
}
override bool isPending(TimerID timer)
{
assert(false, "TODO!");
}
override bool isPeriodic(TimerID timer)
{
assert(false, "TODO!");
}
override void wait(TimerID timer, TimerCallback callback)
{
assert(false, "TODO!");
}
override void cancelWait(TimerID timer, TimerCallback callback)
{
assert(false, "TODO!");
}
override void addRef(TimerID descriptor)
{
assert(false, "TODO!");
}
override void releaseRef(TimerID descriptor)
{
assert(false, "TODO!");
}
}
final class LibasyncEventDriverWatchers : EventDriverWatchers {
@safe: /*@nogc:*/ nothrow:
override WatcherID watchDirectory(string path, bool recursive)
{
assert(false, "TODO!");
}
override void wait(WatcherID watcher, FileChangesCallback callback)
{
assert(false, "TODO!");
}
override void cancelWait(WatcherID watcher)
{
assert(false, "TODO!");
}
override void addRef(WatcherID descriptor)
{
assert(false, "TODO!");
}
override void releaseRef(WatcherID descriptor)
{
assert(false, "TODO!");
}
}