Skip to content

[Android][Linux] Fixed hang when using RunLoop.main.run with Date() #2544

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 19, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CoreFoundation/RunLoop.subproj/CFRunLoop.c
Original file line number Diff line number Diff line change
Expand Up @@ -2846,7 +2846,7 @@ static int32_t __CFRunLoopRun(CFRunLoopRef rl, CFRunLoopModeRef rlm, CFTimeInter
// Here, use the app-supplied message queue mask. They will set this if they are interested in having this run loop receive windows messages.
__CFRunLoopWaitForMultipleObjects(waitSet, NULL, poll ? 0 : TIMEOUT_INFINITY, rlm->_msgQMask, &livePort, &windowsMessageReceived);
#elif TARGET_OS_LINUX
__CFRunLoopServiceFileDescriptors(waitSet, CFPORT_NULL, TIMEOUT_INFINITY, &livePort);
__CFRunLoopServiceFileDescriptors(waitSet, CFPORT_NULL, poll ? 0 : TIMEOUT_INFINITY, &livePort);
#endif

__CFRunLoopLock(rl);
Expand Down
11 changes: 11 additions & 0 deletions TestFoundation/TestRunLoop.swift
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,16 @@ class TestRunLoop : XCTestCase {

XCTAssertLessThan(abs(timerTickInterval - expectedTimeInterval), 0.01)
}

func test_runLoopPoll() {
let runLoop = RunLoop.current

let startDate = Date()
runLoop.run(until: Date())
let endDate = Date()

XCTAssertLessThan(endDate.timeIntervalSince(startDate), 0.5)
}

func test_commonModes() {
let runLoop = RunLoop.current
Expand Down Expand Up @@ -123,6 +133,7 @@ class TestRunLoop : XCTestCase {
// these tests do not work the same as Darwin https://bugs.swift.org/browse/SR-399
// ("test_runLoopRunMode", test_runLoopRunMode),
// ("test_runLoopLimitDate", test_runLoopLimitDate),
("test_runLoopPoll", test_runLoopPoll),
("test_addingRemovingPorts", test_addingRemovingPorts),
]
}
Expand Down