GCDSwift 0.2.0

GCDSwift 0.2.0

LangLanguage SwiftSwift
License MIT
ReleasedLast Release Sep 2015
SPMSupports SPM

Maintained by Mark Smith.

GCDSwift 0.2.0

  • By
  • Mark Smith


GCDSwift is a Swift wrapper for the most commonly used features of Grand Central Dispatch. It has four main aims:

  • Organize the flat C API into appropriate classes.
  • Use intention-revealing names to distinguish between synchronous and asynchronous functions.
  • Use more convenient arguments such as time intervals.
  • Add convenience methods.

GCDSwift defines the same API as GCDObjC.


GCDSwift requires Swift 2.0.

For usage examples, see GCDSwiftTests.m.


Queues are implemented in the GCDQueue class.

  • convenience accessors for global queues
class var mainQueue: GCDQueue { get }
class var globalQueue: GCDQueue { get }
class var highPriorityGlobalQueue: GCDQueue { get }
class var lowPriorityGlobalQueue: GCDQueue { get }
class var backgroundPriorityGlobalQueue: GCDQueue { get }
  • creating serial and concurrent queues
class func serialQueue() -> GCDQueue
class func concurrentQueue() -> GCDQueue
  • queueing blocks for asynchronous execution
func queueBlock(block: dispatch_block_t)
func queueBlock(block: dispatch_block_t, afterDelay seconds: Double)
func queueBlock(block: dispatch_block_t, inGroup group: GCDGroup)
  • queueing blocks for synchronous execution
func queueAndAwaitBlock(block: dispatch_block_t)
func queueAndAwaitBlock(block: ((Int) -> Void), iterationCount count: Int)
  • queueing barrier blocks for synchronous or asynchronous execution
func queueBarrierBlock(block: dispatch_block_t)
func queueAndAwaitBarrierBlock(block: dispatch_block_t)
  • queueing notify blocks on groups
func queueNotifyBlock(block: dispatch_block_t, inGroup group: GCDGroup)
  • suspending and resuming a queue
func suspend()
func resume()


Semaphores are implemented in the GCDSemaphore class.

  • creating semaphores
GCDSemaphore(value: CLong)
  • signaling and waiting on a semaphore
func signal() -> Bool
func wait()
func wait(seconds: Double) -> Bool


Groups are implemented in the GCDGroup class.

  • creating groups
  • entering and leaving a group
func enter()
func leave()
  • waiting on completion of a group
func wait()
func wait(seconds: Double) -> Bool