{"id":15050762,"url":"https://github.com/thisandagain/queue","last_synced_at":"2025-10-24T04:29:04.408Z","repository":{"id":3761416,"uuid":"4837591","full_name":"thisandagain/queue","owner":"thisandagain","description":"A persistent background job queue for iOS.","archived":false,"fork":false,"pushed_at":"2017-06-12T09:06:14.000Z","size":139,"stargazers_count":268,"open_issues_count":8,"forks_count":43,"subscribers_count":20,"default_branch":"master","last_synced_at":"2025-10-10T16:39:30.375Z","etag":null,"topics":["objective-c","queue"],"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/thisandagain.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-06-29T21:52:16.000Z","updated_at":"2023-12-14T18:00:53.000Z","dependencies_parsed_at":"2022-08-17T23:00:38.780Z","dependency_job_id":null,"html_url":"https://github.com/thisandagain/queue","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/thisandagain/queue","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisandagain%2Fqueue","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisandagain%2Fqueue/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisandagain%2Fqueue/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisandagain%2Fqueue/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thisandagain","download_url":"https://codeload.github.com/thisandagain/queue/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thisandagain%2Fqueue/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016928,"owners_count":26085888,"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","status":"online","status_checked_at":"2025-10-13T02:00:06.723Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["objective-c","queue"],"created_at":"2024-09-24T21:29:16.374Z","updated_at":"2025-10-13T19:38:04.407Z","avatar_url":"https://github.com/thisandagain.png","language":"Objective-C","readme":"## Queue\n#### A persistent background job queue for iOS.\n\nWhile `NSOperation` and `NSOperationQueue` work well for some repetitive problems and `NSInvocation` for others, iOS doesn't really include a set of tools for managing large collections of arbitrary background tasks easily. **EDQueue provides a high-level interface for implementing a threaded job queue using [GCD](http://developer.apple.com/library/ios/#documentation/Performance/Reference/GCD_libdispatch_Ref/Reference/reference.html) and [SQLLite3](http://www.sqlite.org/). All you need to do is handle the jobs within the provided delegate method and EDQueue handles the rest.**\n\n### Getting Started\nThe easiest way to get going with EDQueue is to take a look at the included example application. The Xcode project file can be found in `Project \u003e queue.xcodeproj`.\n\n### Setup\nEDQueue needs both `libsqlite3.0.dylib` and [FMDB](https://github.com/ccgus/fmdb) for the storage engine. As always, the quickest way to take care of all those details is to use [CocoaPods](http://cocoapods.org/). EDQueue is implemented as a singleton as to allow jobs to be created from anywhere throughout an application. However, tasks are all processed through a single delegate method and thus it often makes the most sense to setup EDQueue within the application delegate:\n\nYourAppDelegate.h\n```objective-c\n#import \"EDQueue.h\"\n```\n```objective-c\n@interface YourAppDelegate : UIResponder \u003cUIApplicationDelegate, EDQueueDelegate\u003e\n```\n\nYourAppDelegate.m\n```objective-c\n- (void)applicationDidBecomeActive:(UIApplication *)application\n{\n    [[EDQueue sharedInstance] setDelegate:self];\n    [[EDQueue sharedInstance] start];\n}\n\n- (void)applicationWillResignActive:(UIApplication *)application\n{\n    [[EDQueue sharedInstance] stop];\n}\n\n- (EDQueueResult)queue:(EDQueue *)queue processJob:(NSDictionary *)job\n{\n    sleep(1);           // This won't block the main thread. Yay!\n    \n    // Wrap your job processing in a try-catch. Always use protection!\n    @try {\n        if ([[job objectForKey:@\"task\"] isEqualToString:@\"success\"]) {\n            return EDQueueResultSuccess;\n        } else if ([[job objectForKey:@\"task\"] isEqualToString:@\"fail\"]) {\n            return EDQueueResultFail;\n        }\n    }\n    @catch (NSException *exception) {\n        return EDQueueResultCritical;\n    }\n    \n    return EDQueueResultCritical;\n}\n```\n\nSomewhereElse.m\n```objective-c\n[[EDQueue sharedInstance] enqueueWithData:@{ @\"foo\" : @\"bar\" } forTask:@\"nyancat\"];\n```\n\nIn order to keep things simple, the delegate method expects a return type of `EDQueueResult` which permits three distinct states:\n- `EDQueueResultSuccess`: Used to indicate that a job has completed successfully\n- `EDQueueResultFail`: Used to indicate that a job has failed and should be retried (up to the specified `retryLimit`)\n- `EDQueueResultCritical`: Used to indicate that a job has failed critically and should not be attempted again\n\n### Handling Async Jobs\nAs of v0.6.0 queue includes a delegate method suited for handling asyncronous jobs such as HTTP requests or [Disk I/O](https://github.com/thisandagain/storage):\n\n```objective-c\n- (void)queue:(EDQueue *)queue processJob:(NSDictionary *)job completion:(void (^)(EDQueueResult))block\n{\n    sleep(1);\n    \n    @try {\n        if ([[job objectForKey:@\"task\"] isEqualToString:@\"success\"]) {\n            block(EDQueueResultSuccess);\n        } else if ([[job objectForKey:@\"task\"] isEqualToString:@\"fail\"]) {\n            block(EDQueueResultFail);\n        } else {\n            block(EDQueueResultCritical);\n        }\n    }\n    @catch (NSException *exception) {\n        block(EDQueueResultCritical);\n    }\n}\n```\n\n### Introspection\nAs of v0.7.0 queue includes a collection of methods to aid in queue introspection specific to each task:\n```objective-c\n- (Boolean)jobExistsForTask:(NSString *)task;\n- (Boolean)jobIsActiveForTask:(NSString *)task;\n- (NSDictionary *)nextJobForTask:(NSString *)task;\n```\n\n---\n\n### Methods\n```objective-c\n- (void)enqueueWithData:(id)data forTask:(NSString *)task;\n\n- (void)start;\n- (void)stop;\n- (void)empty;\n\n- (Boolean)jobExistsForTask:(NSString *)task;\n- (Boolean)jobIsActiveForTask:(NSString *)task;\n- (NSDictionary *)nextJobForTask:(NSString *)task;\n```\n\n### Delegate Methods\n```objective-c\n- (EDQueueResult)queue:(EDQueue *)queue processJob:(NSDictionary *)job;\n- (void)queue:(EDQueue *)queue processJob:(NSDictionary *)job completion:(void (^)(EDQueueResult result))block;\n```\n\n### Result Types\n```objective-c\nEDQueueResultSuccess\nEDQueueResultFail\nEDQueueResultCritical\n```\n\n### Properties\n```objective-c\n@property (weak) id\u003cEDQueueDelegate\u003e delegate;\n@property (readonly) Boolean isRunning;\n@property (readonly) Boolean isActive;\n@property NSUInteger retryLimit;\n```\n\n### Notifications\n```objective-c\nEDQueueDidStart\nEDQueueDidStop\nEDQueueDidDrain\nEDQueueJobDidSucceed\nEDQueueJobDidFail\n```\n\n---\n\n### iOS Support\nEDQueue is designed for iOS 5 and up.\n\n### ARC\nEDQueue is built using ARC. If you are including EDQueue in a project that **does not** use [Automatic Reference Counting (ARC)](http://developer.apple.com/library/ios/#releasenotes/ObjectiveC/RN-TransitioningToARC/Introduction/Introduction.html), you will need to set the `-fobjc-arc` compiler flag on all of the EDQueue source files. To do this in Xcode, go to your active target and select the \"Build Phases\" tab. Now select all EDQueue source files, press Enter, insert `-fobjc-arc` and then \"Done\" to enable ARC for EDQueue.\n","funding_links":[],"categories":["queue"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthisandagain%2Fqueue","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthisandagain%2Fqueue","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthisandagain%2Fqueue/lists"}