-
Notifications
You must be signed in to change notification settings - Fork 20
Queue
aleclarson edited this page Oct 21, 2014
·
7 revisions
Queue
s manage the execution of closures you give to them.
Serial queues execute their closures one at a time.
Concurrent queues execute their closures many at a time (depending on system conditions).
All queues always execute their closures in order. Serial queues' closures always finish in order. Concurrent queues' closures do not always finish in order.
myQueue.isConcurrent
is useful for knowing what kind of queue you're working with.
Queue
runs on top of the traditional dispatch queue.
gcd.main.async {
let currentQueue: Queue = gcd.current // gcd.main
let queueIsCurrent: Bool = currentQueue.isCurrent // true
}
current
is only available on gcd
.
isCurrent
is available on all Queue
s.
The example below would deadlock the main queue if you weren't using this framework...
gcd.main.sync {
gcd.main.sync { // normally deadlocks
println("hello world")
}
}
Instead, the Queue
just pretends like you did this:
gcd.main.sync {
println("hello world")
}