Merge pull request #148 from vibe-d/cfrunloop_fixes

CFRunLoop fixes
This commit is contained in:
Leonid Kramer 2020-05-25 18:57:28 +02:00 committed by GitHub
commit d52e065605
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 8 additions and 3 deletions

View file

@ -38,7 +38,7 @@ final class CFRunLoopEventLoop : KqueueEventLoopBase {
CFFileDescriptorEnableCallBacks(m_kqueueDescriptor, CFOptionFlags.kCFFileDescriptorReadCallBack);
m_kqueueSource = CFFileDescriptorCreateRunLoopSource(kCFAllocatorDefault, m_kqueueDescriptor, 0);
CFRunLoopAddSource(CFRunLoopGetMain(), m_kqueueSource, kCFRunLoopDefaultMode);
CFRunLoopAddSource(CFRunLoopGetCurrent(), m_kqueueSource, kCFRunLoopDefaultMode);
}
override bool doProcessEvents(Duration timeout)

View file

@ -851,7 +851,11 @@ final class PosixEventDriverSockets(Loop : PosixEventLoop) : EventDriverSockets
}
scope src_addrc = new RefAddress(() @trusted { return cast(sockaddr*)&src_addr; } (), src_addr_len);
on_receive_finish(socket, IOStatus.ok, ret, src_addrc);
if (ret == 0) {
on_receive_finish(socket, IOStatus.disconnected, 0, src_addrc);
} else {
on_receive_finish(socket, IOStatus.ok, ret, src_addrc);
}
}
package void receiveNoGC(DatagramSocketFD socket, ubyte[] buffer, IOMode mode, void delegate(DatagramSocketFD, IOStatus, size_t, scope RefAddress) @safe nothrow @nogc on_receive_finish)

View file

@ -391,7 +391,7 @@ final class FSEventsEventDriverWatchers(Events : EventDriverEvents) : EventDrive
slot.stream = FSEventStreamCreate(null, &onFSEvent, () @trusted { return &ctx; } (),
paths, since_when, 0.1, kFSEventStreamCreateFlagFileEvents|kFSEventStreamCreateFlagNoDefer);
FSEventStreamScheduleWithRunLoop(slot.stream, CFRunLoopGetMain(), kCFRunLoopDefaultMode);
FSEventStreamScheduleWithRunLoop(slot.stream, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
FSEventStreamStart(slot.stream);
m_streamMap[cast(void*)slot.stream] = slot.id;

View file

@ -93,6 +93,7 @@ static if (!is(CFRunLoopRef)) {
extern const CFStringRef kCFRunLoopCommonModes;
CFRunLoopRef CFRunLoopGetMain() @nogc;
CFRunLoopRef CFRunLoopGetCurrent() @nogc;
void CFRunLoopAddSource(CFRunLoopRef rl, CFRunLoopSourceRef source, CFRunLoopMode mode) @nogc;
CFRunLoopRunResult CFRunLoopRunInMode(CFRunLoopMode mode, CFTimeInterval seconds, Boolean returnAfterSourceHandled);
}