Skip to content

Commit 0bb6d51

Browse files
committed
Imlpemented main
1 parent 7d9d884 commit 0bb6d51

File tree

2 files changed

+16
-6
lines changed

2 files changed

+16
-6
lines changed

ExecutionContext/ExecutionContext.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,3 +167,13 @@ public func sleep(timeout:Double) {
167167

168168
nanosleep(&time, nil)
169169
}
170+
171+
@noreturn public func executionContextMain() {
172+
#if os(Linux)
173+
while true {
174+
CFRunLoopRunInMode(defaultMode, 0, true)
175+
}
176+
#else
177+
dispatch_main()
178+
#endif
179+
}

ExecutionContext/PThreadExecutionContext.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -207,15 +207,15 @@
207207
}
208208
}
209209

210+
#if !os(Linux)
211+
private let defaultMode:CFString = "kCFRunLoopDefaultMode" as NSString
212+
#else
213+
private let defaultMode:CFString = "kCFRunLoopDefaultMode".bridge().cfString
214+
#endif
215+
210216
private class SerialContext : ExecutionContextBase, ExecutionContextType {
211217
private let rl:CFRunLoop!
212218
private let finalizer: RunLoopFinalizer?
213-
214-
#if !os(Linux)
215-
private static let defaultMode:CFString = "kCFRunLoopDefaultMode" as NSString
216-
#else
217-
private static let defaultMode:CFString = "kCFRunLoopDefaultMode".bridge().cfString
218-
#endif
219219

220220
override init() {
221221
var runLoop:CFRunLoop?

0 commit comments

Comments
 (0)