{"id":22828753,"url":"https://github.com/mjmsmith/gcdobjc","last_synced_at":"2025-04-06T18:15:36.718Z","repository":{"id":3623235,"uuid":"4689183","full_name":"mjmsmith/gcdobjc","owner":"mjmsmith","description":"Objective-C wrapper for Grand Central Dispatch","archived":false,"fork":false,"pushed_at":"2017-07-17T03:59:39.000Z","size":49,"stargazers_count":351,"open_issues_count":0,"forks_count":34,"subscribers_count":11,"default_branch":"master","last_synced_at":"2025-03-30T16:12:53.847Z","etag":null,"topics":["cocoapods","gcd","grand-central-dispatch","ios"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mjmsmith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-17T02:43:04.000Z","updated_at":"2025-02-24T07:12:43.000Z","dependencies_parsed_at":"2022-09-23T03:42:33.879Z","dependency_job_id":null,"html_url":"https://github.com/mjmsmith/gcdobjc","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjmsmith%2Fgcdobjc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjmsmith%2Fgcdobjc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjmsmith%2Fgcdobjc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mjmsmith%2Fgcdobjc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mjmsmith","download_url":"https://codeload.github.com/mjmsmith/gcdobjc/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247526764,"owners_count":20953143,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","gcd","grand-central-dispatch","ios"],"created_at":"2024-12-12T19:12:02.814Z","updated_at":"2025-04-06T18:15:36.682Z","avatar_url":"https://github.com/mjmsmith.png","language":"Objective-C","readme":"# GCDObjC\n\nGCDObjC is an Objective-C wrapper for the most commonly used features of Grand Central Dispatch.  It has four main aims:\n\n* Organize the flat C API into appropriate classes.\n* Use intention-revealing names to distinguish between synchronous and asynchronous functions. \n* Use more convenient arguments such as time intervals.\n* Add convenience methods.\n\n**A Swift port is at [GCDSwift](https://github.com/mjmsmith/gcdswift).**\n\n## Usage\n\n__GCDObjC__ requires ARC and iOS 6.0.  (Prior to 6.0, dispatch objects were not considered Objective-C objects, and therefore required manual memory management.)\n\n__GCDObjC.h__ is the only header file that needs to be imported.\n\nFor usage examples, see [GCDObjCTests.m](https://github.com/mjmsmith/gcdobjc/blob/master/GCDObjCTests/GCDObjCTests.m).\n\nInstall via CocoaPods:\n\n```ruby\npod \"GCDObjC\"\n```\n\n## GCDQueue\n\nQueues are implemented in the __GCDQueue__ class.\n\n* convenience accessors for global queues\n\n```objc\n+ (GCDQueue *)mainQueue;\n+ (GCDQueue *)globalQueue;\n+ (GCDQueue *)highPriorityGlobalQueue;\n+ (GCDQueue *)lowPriorityGlobalQueue;\n+ (GCDQueue *)backgroundPriorityGlobalQueue;\n```\n\n* testing the current execution context\n\n```objc\n+ (BOOL)isMainQueue;\n```\n\n* creating serial and concurrent queues\n\n```objc\n- (instancetype)initSerial;\n- (instancetype)initConcurrent;\n```\n\n* queueing blocks for asynchronous execution\n\n```objc\n- (void)queueBlock:(dispatch_block_t)block;\n- (void)queueBlock:(dispatch_block_t)block afterDelay:(double)seconds;\n- (void)queueBlock:(dispatch_block_t)block inGroup:(GCDGroup *)group;\n```\n\n* queueing blocks for synchronous execution\n\n```objc\n- (void)queueAndAwaitBlock:(dispatch_block_t)block;\n- (void)queueAndAwaitBlock:(void (^)(size_t))block iterationCount:(size_t)count;\n```\n\n* queueing barrier blocks for synchronous or asynchronous execution\n\n```objc\n- (void)queueBarrierBlock:(dispatch_block_t)block;\n- (void)queueAndAwaitBarrierBlock:(dispatch_block_t)block;\n```\n\n* queueing notify blocks on groups\n\n```objc\n- (void)queueNotifyBlock:(dispatch_block_t)block inGroup:(GCDGroup *)group;\n```\n\n* suspending and resuming a queue\n\n```objc\n- (void)suspend;\n- (void)resume;\n```\n\n* associating context data with a key\n\n```objc\n- (void *)contextForKey:(const void *)key;\n- (void)setContext:(void *)context forKey:(const void *)key;\n```\n\n## GCDSemaphore\n\nSemaphores are implemented in the __GCDSemaphore__ class.\n\n* creating semaphores\n\n```objc\n- (instancetype)init;\n- (instancetype)initWithValue:(long)value;\n```\n\n* signaling and waiting on a semaphore\n\n```objc\n- (BOOL)signal;\n- (void)wait;\n- (BOOL)wait:(double)seconds;\n```\n\n## GCDGroup\n\nGroups are implemented in the __GCDGroup__ class.\n\n* creating groups\n\n```objc\n- (instancetype)init;\n```\n\n* entering and leaving a group\n\n```objc\n- (void)enter;\n- (void)leave;\n```\n\n* waiting on completion of a group\n\n```objc\n- (void)wait;\n- (BOOL)wait:(double)seconds;\n```\n\n## Macros\n\nTwo macros are provided for wrapping __dispatch_once()__ calls.\n\n* executing a block only once: __GCDExecOnce(block)__\n\n```objc\nfor (int i = 0; i \u003c 10; ++i) {\n    GCDExecOnce(^{ NSLog(@\"This will only be logged once.\"); });\n}\n```\n\n* creating a singleton instance of a class: __GCDSharedInstance(block)__\n\n```objc\n+ (instancetype)sharedInstance {\n  GCDSharedInstance(^{ return [self new]; });\n}\n```\n\nThe block supplied to __GCDSharedInstance()__ must return an instance of the desired class.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjmsmith%2Fgcdobjc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmjmsmith%2Fgcdobjc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmjmsmith%2Fgcdobjc/lists"}