{"id":15561255,"url":"https://github.com/space-code/concurrency","last_synced_at":"2026-02-10T21:32:03.950Z","repository":{"id":79213893,"uuid":"587638407","full_name":"space-code/concurrency","owner":"space-code","description":"concurrency  is a modern, testable Swift framework that provides elegant abstractions for Grand Central Dispatch (GCD) primitives","archived":false,"fork":false,"pushed_at":"2026-01-27T01:02:46.000Z","size":378,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-01-27T13:06:45.147Z","etag":null,"topics":["async","concurrency","dispatch-queues","gcd","qos","queue","swift","swift-concurrency"],"latest_commit_sha":null,"homepage":"","language":"Swift","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/space-code.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2023-01-11T08:19:59.000Z","updated_at":"2026-01-27T01:02:49.000Z","dependencies_parsed_at":null,"dependency_job_id":"8ab4054f-fe58-4eed-9f97-f45e0b902fca","html_url":"https://github.com/space-code/concurrency","commit_stats":{"total_commits":6,"total_committers":1,"mean_commits":6.0,"dds":0.0,"last_synced_commit":"880aeaebc920ed3046c8d96e7ea85ea0e6662a07"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/space-code/concurrency","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Fconcurrency","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Fconcurrency/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Fconcurrency/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Fconcurrency/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/space-code","download_url":"https://codeload.github.com/space-code/concurrency/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/space-code%2Fconcurrency/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29317956,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-10T20:44:44.282Z","status":"ssl_error","status_checked_at":"2026-02-10T20:44:43.393Z","response_time":65,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["async","concurrency","dispatch-queues","gcd","qos","queue","swift","swift-concurrency"],"created_at":"2024-10-02T16:06:47.766Z","updated_at":"2026-02-10T21:32:03.939Z","avatar_url":"https://github.com/space-code.png","language":"Swift","readme":"![concurrency: A collection of concurrency primitives](./Resources/concurrency.png)\n\n\u003ch1 align=\"center\" style=\"margin-top: 0px;\"\u003econcurrency\u003c/h1\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/space-code/concurrency/blob/main/LICENSE\"\u003e\u003cimg alt=\"License\" src=\"https://img.shields.io/github/license/space-code/concurrency?style=flat\"\u003e\u003c/a\u003e \n\u003ca href=\"https://swiftpackageindex.com/space-code/concurrency\"\u003e\u003cimg alt=\"Swift Compatibility\" src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fspace-code%2Fconcurrency%2Fbadge%3Ftype%3Dswift-versions\"\u003e\u003c/a\u003e\n\u003ca href=\"https://swiftpackageindex.com/space-code/concurrency\"\u003e\u003cimg alt=\"Platform Compatibility\" src=\"https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2Fspace-code%2Fconcurrency%2Fbadge%3Ftype%3Dplatforms\"/\u003e\u003c/a\u003e \n\u003ca href=\"https://github.com/space-code/concurrency/actions/workflows/ci.yml\"\u003e\u003cimg alt=\"CI\" src=\"https://github.com/space-code/concurrency/actions/workflows/ci.yml/badge.svg?branch=main\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/apple/swift-package-manager\" alt=\"concurrency on Swift Package Manager\" title=\"concurrency on Swift Package Manager\"\u003e\u003cimg src=\"https://img.shields.io/badge/Swift%20Package%20Manager-compatible-brightgreen.svg\" /\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n## Description\n\n`concurrency` is a modern, testable Swift framework that provides elegant abstractions for Grand Central Dispatch (GCD) primitives. Built with testability in mind, it enables you to write concurrent code that's easy to test and maintain.\n\n## Features\n✨ **Type-Safe Queue Abstractions** - Clean interfaces for main, global, and custom queues  \n🧪 **Built for Testing** - Comes with dedicated test doubles for unit testing  \n⚡ **Lightweight** - Minimal wrapper around GCD with zero overhead  \n🎯 **Protocol-Based** - Easy to mock and inject dependencies  \n📱 **Cross-Platform** - Works on iOS, macOS, tvOS, watchOS, and visionOS  \n\n## Table of Contents\n\n- [Requirements](#requirements)\n- [Installation](#installation)\n- [Quick Start](#quick-start)\n- [Usage](#usage)\n  - [Dispatch Queue Factory](#dispatch-queue-factory)\n  - [Main Queue](#main-queue)\n  - [Global Queue](#global-queue)\n  - [Private Queue](#private-queue)\n  - [Testing](#testing)\n- [Communication](#communication)\n- [Contributing](#contributing)\n  - [Development Setup](#development-setup)\n- [Author](#author)\n- [License](#license)\n\n## Requirements\n\n| Platform  | Minimum Version |\n|-----------|----------------|\n| iOS       | 13.0+          |\n| macOS     | 10.15+         |\n| tvOS      | 13.0+          |\n| watchOS   | 6.0+           |\n| visionOS  | 1.0+           |\n| Xcode     | 15.3+          |\n| Swift     | 5.10+          |\n\n## Installation\n\n### Swift Package Manager\n\nAdd the following dependency to your `Package.swift`:\n\n```swift\ndependencies: [\n    .package(url: \"https://github.com/space-code/concurrency.git\", from: \"0.3.1\")\n]\n```\n\nOr add it through Xcode:\n\n1. File \u003e Add Package Dependencies\n2. Enter package URL: `https://github.com/space-code/concurrency.git`\n3. Select version requirements\n\n## Quick Start\n\n```swift\nimport Concurrency\n\n// Create a queue factory\nlet factory = DispatchQueueFactory()\n\n// Use the main queue for UI updates\nlet mainQueue = factory.main()\nmainQueue.async {\n    // Update UI safely\n    updateLabel()\n}\n\n// Use a background queue for heavy work\nlet backgroundQueue = factory.global(qos: .background)\nbackgroundQueue.async {\n    processLargeDataset()\n}\n```\n\n## Usage\n\n### Dispatch Queue Factory\n\nThe DispatchQueueFactory is your entry point for creating all types of dispatch queues:\n\n```swift\nimport Concurrency\n\nlet factory = DispatchQueueFactory()\n```\n\n### Main Queue\n\nPerfect for UI updates and ensuring code runs on the main thread:\n\n```swift\nimport Concurrency\n\nclass ViewController {\n    private let factory = DispatchQueueFactory()\n    private lazy var mainQueue = factory.main()\n    \n    func updateUI(with data: Data) {\n        mainQueue.async {\n            self.label.text = String(data: data, encoding: .utf8)\n            self.refreshButton.isEnabled = true\n        }\n    }\n}\n```\n\n### Global Queue\n\nAccess system-provided concurrent queues with different quality of service levels:\n\n```swift\nimport Concurrency\n\nclass DataProcessor {\n    private let factory = DispatchQueueFactory()\n    \n    func processInBackground() {\n        // High priority background work\n        let userInitiatedQueue = factory.global(qos: .userInitiated)\n        userInitiatedQueue.async {\n            self.performCriticalProcessing()\n        }\n        \n        // Low priority background work\n        let backgroundQueue = factory.global(qos: .background)\n        backgroundQueue.async {\n            self.performMaintenanceTasks()\n        }\n    }\n}\n```\n\n**Quality of Service Levels:**\n\n- `.userInteractive` - Work that is interacting with the user (animations, event handling)  \n- `.userInitiated` - Work initiated by the user that prevents further interaction  \n- `.default` - Default priority for work  \n- `.utility` - Long-running tasks with user-visible progress  \n- `.background` - Work not visible to the user (prefetching, maintenance)  \n- `.unspecified` - Absence of QoS information`  \n\n### Private Queue\n\nCreate custom queues with fine-grained control:\n\n```swift\nimport Concurrency\n\nclass NetworkManager {\n    private let factory = DispatchQueueFactory()\n    \n    // Serial queue for thread-safe access\n    private lazy var serialQueue = factory.privateQueue(\n        label: \"com.example.network.serial\",\n        qos: .userInitiated,\n        attributes: [],\n        autoreleaseFrequency: .inherit,\n        target: nil\n    )\n    \n    // Concurrent queue for parallel processing\n    private lazy var concurrentQueue = factory.privateQueue(\n        label: \"com.example.network.concurrent\",\n        qos: .utility,\n        attributes: .concurrent,\n        autoreleaseFrequency: .workItem,\n        target: nil\n    )\n    \n    func processRequests(_ requests: [Request]) {\n        concurrentQueue.async {\n            requests.forEach { request in\n                self.process(request)\n            }\n        }\n    }\n}\n```\n\n**Parameters**:\n\n- `label` - Unique identifier for debugging  \n- `qos` - Quality of service class  \n- `attributes` - .concurrent for concurrent execution, empty for serial  \n- `autoreleaseFrequency` - Memory management strategy  \n- `target` - Queue to execute blocks on (advanced usage)  \n\n## Testing\n\nConcurrency includes a dedicated test target with synchronous test doubles:\n\n```swift\nimport TestConcurrency\nimport XCTest\n\nclass ViewModelTests: XCTestCase {\n    func testDataFetching() {\n        // Create test queue that executes immediately\n        let testQueue = TestDispatchQueue()\n        let viewModel = ViewModel(queue: testQueue)\n        \n        // Runs block immediately\n        testQueue.async {}\n\n        // No need for expectations - execution is synchronous\n        viewModel.fetchData()\n        \n        // Assert immediately\n        XCTAssertTrue(viewModel.isLoading)\n    }\n}\n```\n\n**Injecting Queues for Testability:**\n\n```swift\nimport Concurrency\n\nprotocol DispatchQueueType {\n    func async(execute work: @escaping () -\u003e Void)\n    func sync(execute work: () -\u003e Void)\n}\n\nextension DispatchQueue: DispatchQueueType {}\n\nclass DataManager {\n    private let factory: IDispatchQueueFactory\n    \n    init(factory: IDispatchQueueFactory) {\n        self.factory = factory\n    }\n    \n    func loadData(completion: @escaping (Result\u003cData, Error\u003e) -\u003e Void) {\n        factory.global(qos: .background).async {\n            // Perform work\n            let result = self.fetchData()\n            completion(result)\n        }\n    }\n}\n```\n\n## Communication\n\n- 🐛 **Found a bug?** [Open an issue](https://github.com/space-code/concurrency/issues/new)\n- 💡 **Have a feature request?** [Open an issue](https://github.com/space-code/concurrency/issues/new)\n- ❓ **Questions?** [Start a discussion](https://github.com/space-code/concurrency/discussions)\n- 🔒 **Security issue?** Email nv3212@gmail.com\n\n## Contributing\n\nWe love contributions! Please feel free to help out with this project. If you see something that could be made better or want a new feature, open up an issue or send a Pull Request.\n\n### Development Setup\n\nBootstrap the development environment:\n\n```bash\nmise install\n```\n\n## Author\n\n**Nikita Vasilev**\n- Email: nv3212@gmail.com\n- GitHub: [@ns-vasilev](https://github.com/ns-vasilev)\n\n## License\n\nConcurrency is released under the MIT license. See [LICENSE](https://github.com/space-code/concurrency/blob/main/LICENSE) for details.\n\n---\n\n\u003cdiv align=\"center\"\u003e\n\n**[⬆ back to top](#concurrency)**\n\nMade with ❤️ by [space-code](https://github.com/space-code)\n\n\u003c/div\u003e","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspace-code%2Fconcurrency","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspace-code%2Fconcurrency","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspace-code%2Fconcurrency/lists"}