swiftlang/swift-corelibs-libdispatch logo

swiftlang/swift-corelibs-libdispatch

Free

The libdispatch Project, (a.k.a. Grand Central Dispatch), for concurrency on multicore hardware

FreeFree tier
Type
Open Source

About swiftlang/swift-corelibs-libdispatch

Grand Central Dispatch (GCD or libdispatch) is a comprehensive library for concurrent code execution on multicore hardware. Originally available on Darwin platforms, this open-source project (swift-corelibs-libdispatch) ports a modern version of libdispatch to other Swift platforms, most notably Linux. The implementation uses user-space pthread primitives on Linux, enabling Swift applications to leverage GCD's concurrency model. It has been included in all Swift releases since Swift 3 and is used by other swift-corelibs projects. The project is maintained under the Apache 2.0 license and provides a test suite for validation.

Key Features

Comprehensive support for concurrent code execution on multicore hardware
Port of libdispatch to non-Darwin platforms, including Linux
Implements a portable subset of the GCD API using user-space pthread primitives
Part of the Swift Core Libraries and included in Swift releases since Swift 3
Open source under Apache 2.0 license with a test suite and build instructions
Designed to eventually support a kernel module for improved scheduling on Linux
Actively developed by the Swift community with contributions welcome

Pros & Cons

Pros
  • Open source (Apache 2.0 license) with permissive usage and contributions
  • Brings GCD to Linux, unifying concurrency patterns across Swift platforms
  • Actively maintained as part of the Swift project and used by swift-corelibs
  • Well-documented with INSTALL.md, TESTING.md, and code of conduct
  • Provides a test suite for verifying correctness and performance
Cons
  • Linux implementation currently uses user-space pthreads, lacking kernel-level scheduling optimization
  • May not have full feature parity with Darwin's libdispatch (e.g., kernel integration)
  • Limited to platforms supported by Swift (primarily Linux; other platforms may require additional work)
  • Primarily a library for developers, not a standalone application with a UI

Best For

Enabling Grand Central Dispatch concurrency on Linux for Swift applicationsBuilding concurrent Swift libraries and frameworks that depend on GCDPorting Darwin-based Swift code that uses GCD to other platformsEducational use for understanding portable concurrency implementations

FAQ

What is Grand Central Dispatch (libdispatch)?
Grand Central Dispatch (GCD or libdispatch) is a library that provides comprehensive support for concurrent code execution on multicore hardware, originally developed by Apple for Darwin platforms.
What platforms does this project support?
libdispatch is currently available on all Darwin platforms. This project ports libdispatch to other Swift platforms, with a completed port for Linux included in Swift releases since Swift 3.
How is libdispatch implemented on Linux?
On Linux, the library uses user-space pthread primitives. Future work may include a Linux kernel module for more informed thread scheduling.
How do I build and install libdispatch?
Detailed instructions for building and installing libdispatch can be found in the INSTALL.md file in the repository.
Is libdispatch open source?
Yes, this project is open source under the Apache 2.0 license.