Last active
March 13, 2021 20:28
-
-
Save drewmccormack/16a36492c495fa833743 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dispatch | |
// | |
// Usage: | |
// Async dispatch to main queue | |
// -->block | |
// Async dispatch to queue | |
// queue --> block | |
// Sync dispatch to main queue | |
// -->|block | |
// Sync dispatch to queue | |
// queue -->| block | |
// | |
operator prefix --> {} | |
operator infix --> {} | |
operator prefix -->| {} | |
operator infix -->| {} | |
@prefix func --> (block:(Void->Void)?) { | |
dispatch_get_main_queue() --> block | |
} | |
@infix func --> (queue:dispatch_queue_t, block:(Void->Void)?) { | |
if block { | |
dispatch_async(queue, block!) | |
} | |
} | |
@prefix func -->| (block:(Void->Void)?) { | |
dispatch_get_main_queue() -->| block | |
} | |
@infix func -->| (queue:dispatch_queue_t, block:(Void->Void)?) { | |
if block { | |
dispatch_sync(queue, block!) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment