File tree Expand file tree Collapse file tree 1 file changed +5
-3
lines changed
source/eventcore/drivers/winapi Expand file tree Collapse file tree 1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change @@ -30,7 +30,7 @@ final class WinAPIEventDriverEvents : EventDriverEvents {
3030 EventSlot[EventID] m_events;
3131 CRITICAL_SECTION m_mutex;
3232 ConsumableQueue! Trigger m_pending;
33- uint m_idCounter;
33+ static shared uint m_idCounter;
3434 }
3535
3636 this (WinAPIEventDriverCore core)
@@ -70,8 +70,10 @@ final class WinAPIEventDriverEvents : EventDriverEvents {
7070
7171 override EventID create ()
7272 {
73- auto id = EventID(m_idCounter++ , 0 );
74- if (id == EventID.invalid) id = EventID(m_idCounter++ , 0 );
73+ import core.atomic : atomicOp;
74+
75+ auto id = EventID(atomicOp! " +=" (m_idCounter, 1 ), 0 );
76+ if (id == EventID.invalid) id = EventID(atomicOp! " +=" (m_idCounter, 1 ), 0 );
7577 m_events[id] = EventSlot(1 , new ConsumableQueue! EventCallback); // FIXME: avoid GC allocation
7678 debug (EventCoreLeakTrace) {
7779 import core.runtime : defaultTraceHandler;
You can’t perform that action at this time.
0 commit comments