Fix CFRunLoop selection in multi-threaded scenarios.
CFRunLoopGetMain returns the main thread's run loop, as opposed to the one belonging to the calling thread.
This commit is contained in:
parent
fd462d89f1
commit
167745efb0
|
@ -38,7 +38,7 @@ final class CFRunLoopEventLoop : KqueueEventLoopBase {
|
||||||
|
|
||||||
CFFileDescriptorEnableCallBacks(m_kqueueDescriptor, CFOptionFlags.kCFFileDescriptorReadCallBack);
|
CFFileDescriptorEnableCallBacks(m_kqueueDescriptor, CFOptionFlags.kCFFileDescriptorReadCallBack);
|
||||||
m_kqueueSource = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, m_kqueueDescriptor, 0);
|
m_kqueueSource = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, m_kqueueDescriptor, 0);
|
||||||
CFRunLoopAddSource(CFRunLoopGetMain(), m_kqueueSource, kCFRunLoopDefaultMode);
|
CFRunLoopAddSource(CFRunLoopGetCurrent(), m_kqueueSource, kCFRunLoopDefaultMode);
|
||||||
}
|
}
|
||||||
|
|
||||||
override bool doProcessEvents(Duration timeout)
|
override bool doProcessEvents(Duration timeout)
|
||||||
|
|
|
@ -391,7 +391,7 @@ final class FSEventsEventDriverWatchers(Events : EventDriverEvents) : EventDrive
|
||||||
|
|
||||||
slot.stream = FSEventStreamCreate(null, &onFSEvent, () @trusted { return &ctx; } (),
|
slot.stream = FSEventStreamCreate(null, &onFSEvent, () @trusted { return &ctx; } (),
|
||||||
paths, since_when, 0.1, kFSEventStreamCreateFlagFileEvents|kFSEventStreamCreateFlagNoDefer);
|
paths, since_when, 0.1, kFSEventStreamCreateFlagFileEvents|kFSEventStreamCreateFlagNoDefer);
|
||||||
FSEventStreamScheduleWithRunLoop(slot.stream, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
|
FSEventStreamScheduleWithRunLoop(slot.stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
|
||||||
FSEventStreamStart(slot.stream);
|
FSEventStreamStart(slot.stream);
|
||||||
|
|
||||||
m_streamMap[cast(void*)slot.stream] = slot.id;
|
m_streamMap[cast(void*)slot.stream] = slot.id;
|
||||||
|
|
|
@ -93,6 +93,7 @@ static if (!is(CFRunLoopRef)) {
|
||||||
extern const CFStringRef kCFRunLoopCommonModes;
|
extern const CFStringRef kCFRunLoopCommonModes;
|
||||||
|
|
||||||
CFRunLoopRef CFRunLoopGetMain() @nogc;
|
CFRunLoopRef CFRunLoopGetMain() @nogc;
|
||||||
|
CFRunLoopRef CFRunLoopGetCurrent() @nogc;
|
||||||
void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFRunLoopMode mode) @nogc;
|
void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFRunLoopMode mode) @nogc;
|
||||||
CFRunLoopRunResult CFRunLoopRunInMode(CFRunLoopMode mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
|
CFRunLoopRunResult CFRunLoopRunInMode(CFRunLoopMode mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue