Update for eventcore 0.5.0 and the latest DMD beta.

This commit is contained in:
Sönke Ludwig 2016-10-24 08:22:37 +02:00
parent d7243dcd39
commit c08f101549
8 changed files with 32 additions and 210 deletions

View file

@ -627,10 +627,10 @@ private TaskFuncInfo makeTaskFuncInfo(CALLABLE, ARGS...)(ref CALLABLE callable,
mixin(callWithMove!ARGS("c", "args.expand"));
}
TaskFuncInfo tfi;
tfi.func = &callDelegate;
return () @trusted {
TaskFuncInfo tfi;
tfi.func = &callDelegate;
() @trusted {
static if (hasElaborateAssign!CALLABLE) tfi.initCallable!CALLABLE();
static if (hasElaborateAssign!TARGS) tfi.initArgs!TARGS();
tfi.typedCallable!CALLABLE = callable;
@ -638,8 +638,8 @@ private TaskFuncInfo makeTaskFuncInfo(CALLABLE, ARGS...)(ref CALLABLE callable,
static if (needsMove!A) args[i].move(tfi.typedArgs!TARGS.expand[i]);
else tfi.typedArgs!TARGS.expand[i] = args[i];
}
return tfi;
} ();
return tfi;
}
@ -1094,7 +1094,7 @@ struct Timer {
if (!this.pending) return;
asyncAwait!(TimerCallback,
cb => m_driver.wait(m_id, cb),
cb => m_driver.cancelWait(m_id, cb)
cb => m_driver.cancelWait(m_id)
);
}
}
@ -1360,7 +1360,7 @@ private void shutdownDriver()
ManualEvent.ms_threadEvent = EventID.init;
}
eventDriver.core.dispose();
eventDriver.dispose();
}
private void workerThreadFunc()

View file

@ -321,7 +321,7 @@ struct TCPConnection {
private this(StreamSocketFD socket)
nothrow {
m_socket = socket;
m_context = &eventDriver.core.userData!Context(socket);
m_context = () @trusted { return &eventDriver.core.userData!Context(socket); } ();
m_context.readBuffer.capacity = 4096;
}
@ -360,7 +360,7 @@ struct TCPConnection {
nothrow {
//logInfo("close %s", cast(int)m_fd);
if (m_socket != StreamSocketFD.invalid) {
eventDriver.sockets.shutdown(m_socket);
eventDriver.sockets.shutdown(m_socket, true, true);
eventDriver.sockets.releaseRef(m_socket);
m_socket = StreamSocketFD.invalid;
m_context = null;

View file

@ -323,7 +323,7 @@ final package class TaskFiber : Fiber {
private void run()
{
import std.encoding : sanitize;
import std.concurrency : Tid;
import std.concurrency : Tid, thisTid;
import vibe.core.core : isEventLoopRunning, recycleFiber, taskScheduler, yield;
version (VibeDebugCatchAll) alias UncaughtException = Throwable;
@ -346,12 +346,12 @@ final package class TaskFiber : Fiber {
m_running = true;
scope(exit) m_running = false;
std.concurrency.thisTid; // force creation of a message box
thisTid; // force creation of a message box
debug if (ms_taskEventCallback) ms_taskEventCallback(TaskEvent.start, handle);
if (!isEventLoopRunning) {
logTrace("Event loop not running at task start - yielding.");
vibe.core.core.taskScheduler.yieldUninterruptible();
taskScheduler.yieldUninterruptible();
logTrace("Initial resume of task.");
}
task.func(&task);
@ -597,7 +597,7 @@ package struct TaskScheduler {
// if the first run didn't process any events, block and
// process one chunk
logTrace("Wait for new events to process...");
er = eventDriver.core.processEvents();
er = eventDriver.core.processEvents(Duration.max);
logTrace("Done.");
final switch (er) {
case ExitReason.exited: return ExitReason.exited;

View file

@ -332,12 +332,16 @@ struct FixedRingBuffer(T, size_t N = 0, bool INITIALIZE = true) {
auto dst = newbuffer;
auto newfill = min(m_fill, new_size);
read(dst[0 .. newfill]);
if (m_freeOnDestruct && m_buffer.length > 0) delete m_buffer;
if (m_freeOnDestruct && m_buffer.length > 0) () @trusted {
delete m_buffer;
} ();
m_buffer = newbuffer;
m_start = 0;
m_fill = newfill;
} else {
if (m_freeOnDestruct && m_buffer.length > 0) delete m_buffer;
if (m_freeOnDestruct && m_buffer.length > 0) () @trusted {
delete m_buffer;
} ();
m_buffer = new T[new_size];
}
}

View file

@ -51,11 +51,11 @@ void asyncAwaitAny(bool interruptible, string func = __FUNCTION__, Waitables...)
import eventcore.core;
auto tm = eventDriver.timers.create();
eventDriver.timers.set(tm, timeout);
eventDriver.timers.set(tm, timeout, 0.seconds);
scope (exit) eventDriver.timers.releaseRef(tm);
Waitable!(
cb => eventDriver.timers.wait(tm, cb),
cb => eventDriver.timers.cancelWait(tm, cb),
cb => eventDriver.timers.cancelWait(tm),
TimerID
) timerwaitable;
asyncAwaitAny!(interruptible, func)(timerwaitable, waitables);