Skip to content

Commit 936c846

Browse files
committed
Added sleep
1 parent 65dbe53 commit 936c846

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

ExecutionContext/ExecutionContext.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,3 +159,11 @@ public let global:ExecutionContextType = ExecutionContext.global
159159
public func executionContext(executor:Executor) -> ExecutionContextType {
160160
return CustomExecutionContext(executor: executor)
161161
}
162+
163+
public func sleep(timeout:Double) {
164+
let sec = time_t(timeout)
165+
let nsec = Int((timeout - Double(sec)) * 1000 * 1000 * 1000)//nano seconds
166+
var time = timespec(tv_sec:sec, tv_nsec: nsec)
167+
168+
nanosleep(&time, nil)
169+
}

0 commit comments

Comments
 (0)