Skip to content

Instantly share code, notes, and snippets.

@ajjames
Last active August 29, 2015 14:13
Show Gist options
  • Select an option

  • Save ajjames/b21e8a9feb16bd011477 to your computer and use it in GitHub Desktop.

Select an option

Save ajjames/b21e8a9feb16bd011477 to your computer and use it in GitHub Desktop.
Dispatch Utility for succinct ways of calling GCD
//
// DispatchUtility.swift
//
// Copyright (c) 2015 Andrew James. All rights reserved.
//
import Foundation
func GCDDispatchMain(closure:()->())
{
dispatch_async(dispatch_get_main_queue(), closure)
}
func GCDDispatchAsyncHigh(closure: ()->())
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_HIGH, 0), closure)
}
func GCDDispatchAsyncDefault(closure: ()->())
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), closure)
}
func GCDDispatchAsyncLow(closure: ()->())
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_LOW, 0), closure)
}
func GCDDispatchAsyncBackground(closure: ()->())
{
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), closure)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment