Skip to content

0.0.1 - Initial Release

Latest

Choose a tag to compare

@scottmarchant scottmarchant released this 17 Oct 22:34
d4251dd

🚀 Initial Release 0.0.1 of DispatchAsync - a pure-swift implementation of libDispatch

The first release of swift-dispatch-async, a lightweight Swift package providing core Grand Central Dispatch (GCD)–APIs implemented using Swift Concurrency. Pure Swift, no direct C or Posix library usage.

Designed to provide support for Swift for WebAssembly / WASI, where the standard Dispatch library has been previously unavailable.

🎯 Overview

  • Implements a minimal compatibility layer for Dispatch APIs using async/await.
  • Enables Swift for WebAssembly builds without modifying code that depends on GCD. You can just replace import Dispatch with import DispatchAsync for most cases.

✅ Features

  • DispatchQueue
    • Supports DispatchQueue.main, DispatchQueue.global(), and custom queues.
    • Provides async(_:) for asynchronous task submission using Swift Concurrency.
  • DispatchWorkItem
    • Lightweight wrapper for units of concurrent work.
    • Can be submitted to queues or executed directly via async tasks.
  • DispatchTime / DispatchWallTime
    • Minimal support for scheduling and time-based operations.
  • DispatchSemaphore
    • Async-safe, non-blocking implementation for single-threaded WASM environments.
    • Balanced wait and signal required; assertions enforce correctness.
  • Conditional Import Support
    • Seamless replacement for Dispatch when unavailable:
      #if os(WASI) && !canImport(Dispatch)
      import DispatchAsync
      #else
      import Dispatch
      #endif
  • Cross-Platform Test Suite
    • Includes tests ported from the original libDispatch project.
    • Validates queue behavior, async scheduling, and semaphore semantics.
  • SwiftPM Integration & Apache-2.0 License

⚠️ Notes

  • Blocking APIs (e.g. sync) are not supported by design.
  • DispatchSemaphore assumes single-threaded execution on WASM.
  • Experimental; behavior may evolve as additional needs evolve.