diff --git a/source/eventcore/drivers/posix.d b/source/eventcore/drivers/posix.d index 99b4760..deaf58d 100644 --- a/source/eventcore/drivers/posix.d +++ b/source/eventcore/drivers/posix.d @@ -1172,7 +1172,7 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS final override void trigger(EventID event, bool notify_all = true) { - auto slot = &getSlot(event); + auto slot = getSlot(event); if (notify_all) { //log("emitting only for this thread (%s waiters)", m_fds[event].waiters.length); foreach (w; slot.waiters.consume) { @@ -1194,7 +1194,7 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS //log("emitting for all threads"); if (notify_all) atomicStore(thisus.getSlot(event).triggerAll, true); version (Windows) - (cast(Sockets)m_sockets).send(cast(DatagramSocketFD)event, cast(ubyte[])m_buf, IOMode.once, null, &onSocketDataSent); + thisus.m_sockets.send(cast(DatagramSocketFD)event, thisus.m_buf, IOMode.once, null, &thisus.onSocketDataSent); else () @trusted { .write(event, &one, one.sizeof); } (); } @@ -1269,14 +1269,14 @@ final class PosixEventDriverEvents(Loop : PosixEventLoop, Sockets : EventDriverS return true; } - private ref EventSlot getSlot(EventID id) + private EventSlot* getSlot(EventID id) { version (Windows) { assert(cast(DatagramSocketFD)id in m_events, "Invalid event ID."); - return m_events[cast(DatagramSocketFD)id]; + return &m_events[cast(DatagramSocketFD)id]; } else { assert(id < m_loop.m_fds.length, "Invalid event ID."); - return m_loop.m_fds[id].event(); + return &m_loop.m_fds[id].event(); } } diff --git a/source/eventcore/drivers/winapi.d b/source/eventcore/drivers/winapi.d index 1daa9d7..5bbed2e 100644 --- a/source/eventcore/drivers/winapi.d +++ b/source/eventcore/drivers/winapi.d @@ -217,14 +217,14 @@ final class WinAPIEventDriverCore : EventDriverCore { if (callback) m_eventCallbacks[event] = callback; } - private ref SlotType setupSlot(SlotType)(HANDLE h) + private SlotType* setupSlot(SlotType)(HANDLE h) { assert(h !in m_handles, "Handle already in use."); HandleSlot s; s.refCount = 1; s.specific = SlotType.init; m_handles[h] = s; - return m_handles[h].specific.get!SlotType; + return () @trusted { return &m_handles[h].specific.get!SlotType(); } (); } private void freeSlot(HANDLE h) @@ -404,7 +404,7 @@ final class WinAPIEventDriverFiles : EventDriverFiles { if (!() @trusted { return GetHandleInformation(handle, &f); } ()) return FileFD.init; - auto s = &m_core.setupSlot!FileSlot(handle); + auto s = m_core.setupSlot!FileSlot(handle); s.read.handle = s.write.handle = handle; return FileFD(system_handle); @@ -413,7 +413,7 @@ final class WinAPIEventDriverFiles : EventDriverFiles { override void close(FileFD file) { auto h = idToHandle(file); - auto slot = &m_core.m_handles[h].file(); + auto slot = () @trusted { return &m_core.m_handles[h].file(); } (); if (slot.read.handle != INVALID_HANDLE_VALUE) { CloseHandle(h); slot.read.handle = slot.write.handle = INVALID_HANDLE_VALUE; @@ -774,7 +774,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers { auto id = WatcherID(cast(int)handle); - auto slot = &m_core.setupSlot!WatcherSlot(handle); + auto slot = m_core.setupSlot!WatcherSlot(handle); slot.directory = path; slot.recursive = recursive; slot.callback = callback; @@ -816,7 +816,7 @@ final class WinAPIEventDriverWatchers : EventDriverWatchers { auto handle = overlapped.hEvent; // *file* handle auto id = WatcherID(cast(int)handle); - auto slot = &WinAPIEventDriver.threadInstance.core.m_handles[handle].watcher(); + auto slot = () @trusted { return &WinAPIEventDriver.threadInstance.core.m_handles[handle].watcher(); } (); if (dwError != 0) { // FIXME: this must be propagated to the caller