{"id":31916940,"url":"https://github.com/swiftlang/swift-platform-executors","last_synced_at":"2025-10-13T20:15:38.089Z","repository":{"id":316082737,"uuid":"1003239682","full_name":"swiftlang/swift-platform-executors","owner":"swiftlang","description":"This package provides platform-native executors for Swift Concurrency.","archived":false,"fork":false,"pushed_at":"2025-09-22T14:45:19.000Z","size":157,"stargazers_count":80,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-09-22T16:32:44.606Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/swiftlang.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":null,"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":"NOTICE.txt","maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-16T20:57:28.000Z","updated_at":"2025-09-22T13:20:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"f178c9fc-058f-4dcb-a250-a511f4c8513d","html_url":"https://github.com/swiftlang/swift-platform-executors","commit_stats":null,"previous_names":["swiftlang/swift-platform-executors"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/swiftlang/swift-platform-executors","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-platform-executors","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-platform-executors/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-platform-executors/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-platform-executors/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/swiftlang","download_url":"https://codeload.github.com/swiftlang/swift-platform-executors/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/swiftlang%2Fswift-platform-executors/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279016939,"owners_count":26085906,"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":[],"created_at":"2025-10-13T20:15:33.016Z","updated_at":"2025-10-13T20:15:38.083Z","avatar_url":"https://github.com/swiftlang.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Swift Platform Executors\n\n\u003e [!WARNING]\n\u003e This package is currently still under active development.\n\nThis package provides platform-native executors for Swift Concurrency.\n\n🚀 Swift package for Swift Concurrency executors\n📦 Compatible with Swift Package Manager\n📱 Supports Linux, Windows, iOS, macOS, watchOS, tvOS, and visionOS\n🔧 Built with Swift 6.2+, Xcode 26+\n\n🔗 Jump to:\n- 📖 [Overview](#overview)\n- ⚙️ [Use Cases](#use-cases)\n- 📋 [Glossary](#glossary)\n- 🏁 [Getting Started](#getting-started)\n- 📘 [Documentation](#documentation)\n- 🧰 [Release Info](#release-info)\n- 💡 [Contributing](#contributing)\n- 🛠️ [Support](#support)\n- 🔐 [Security](#security)\n- 📄 [License](#license)\n\n## 📖 Overview\n\nThis package provides high-performance platform-native executors for Swift\nConcurrency that do not rely on Dispatch or Foundation to provide the job\nscheduling system.\n\n\n## ⚙️ Use Cases\n\nThe executors provided by this package are intended to be used as the default\nexecutors on their respective platform. Furthermore, individual instances\nof these executors can be created to provide custom actor or task executors.\n\n## 🏁 Getting Started\n\n### Prerequisites\n\n- Swift version: 6.2+\n\n### Installation / Integration\n\n#### Adding as a Dependency\n\nTo use Swift Platform Executors in your Swift project, add it as a dependency in\n your `Package.swift` file:\n\n```swift\n.package(\n  url: \"https://github.com/swiftlang/swift-platform-executors\",\n  from: \"0.0.1\"\n),\n```\n\n### Usage\n\nOnce [the relevant Swift Evolution proposal lands](https://github.com/swiftlang/swift-evolution/pull/2654/files),\nit will be possible to replace the default main and global executors with\nexecutors from this package.\n\nTo use the provided executors as the default executors in your application, add\nthe following type alias to the file including your appliation's main entry point.\n\n```swift\nimport PlatformExecutors\n\ntypealias DefaultExecutorFactory = PlatformExecutorFactory\n```\n\nBe aware that if you take advantage of this option, the Dispatch main\nqueue will not be processed, so anything that relies explicitly on\n`Dispatch.main` will not work.\n\n#### Windows\n\n##### `Win32EventLoopExecutor`\n\n`Win32EventLoopExecutor` is a\n[`SerialExecutor`](https://developer.apple.com/documentation/swift/serialexecutor)\nand may be used as a [custom actor executor,\nala\nSE-0392](https://github.com/swiftlang/swift-evolution/blob/main/proposals/0392-custom-actor-executors.md):\n\n```swift\nimport Win32NativeExecutors\n\nactor Win32Actor {\n  nonisolated let executor = Win32EventLoopExecutor()\n\n  nonisolated var unownedExecutor: UnownedSerialExecutor {\n    self.executor.asUnownedSerialExecutor()\n  }\n\n  func greet() {\n    print(\"Hello from a Win32 event loop!\")\n    try? await Task.sleep(for: .seconds(3))\n  }\n}\n\nfunc test() {\n  let myActor = Win32Actor()\n  let t = Task.detached {\n    await myActor.greet()\n    myActor.executor.stop()\n  }\n  myActor.executor.run()\n}\n```\n\nThis will also work for global actors, e.g.\n\n```swift\nimport Win32NativeExecutors\n\n@globalActor\nactor MessageLoopActor {\n  let executor = Win32EventLoopExecutor()\n\n  nonisolated var unownedExecutor: UnownedSerialExecutor {\n    self.executor.asUnownedSerialExecutor()\n  }\n}\n\n@MessageLoopActor\nfunc hello() {\n  print(\"Hello from a Win32 event loop!\")\n  try? await Task.sleep(for: .seconds(3))\n}\n\nfunc test() {\n  let t = Task.detached {\n    await hello()\n    myActor.executor.stop()\n  }\n  myActor.executor.run()\n}\n```\n\nNote that you will need to call the `run()` method on the\n`Win32EventLoopExecutor` from some thread to actually service the\nmessage loop.  This will return on receipt of `WM_QUIT`, or if\nsomething calls the `stop()` method (the latter is thread-safe and can\nbe done asynchronously; the message loop will stop when it is next\nsafe to do so).\n\n###### `Win32ThreadPoolExecutor`\n\nThe `Win32ThreadPoolExecutor` is a\n[`TaskExecutor`](https://developer.apple.com/documentation/swift/taskexecutor) \nbuilt on [the Win32 Thread Pool\nAPI](https://learn.microsoft.com/en-us/windows/win32/procthread/thread-pool-api)\nand can be used with the\n[`withTaskExecutorPreference(_:operation:)`](https://developer.apple.com/documentation/swift/withtaskexecutorpreference(_:isolation:operation:)),\n[`Task(executorPreference:)`](https://developer.apple.com/documentation/swift/task/init(executorpreference:priority:operation:)-7zpzv)\nor [`group.addTask(executorPreference:)`](https://developer.apple.com/documentation/swift/taskgroup/addtask(executorpreference:priority:operation:))\nfamilies of APIs:\n\n```swift\nimport Win32NativeExecutors\n\nlet threadPool = Win32ThreadPoolExecutor()\n\nfunc test() {\n  Task {\n     await withTaskExecutorPreference(threadPool) {\n       print(\"I am running in the default Win32 thread pool\")\n     }\n  }\n}\n```\n\nIf you have a custom Win32 thread pool that you wish to use instead,\nyou can use the `Win32ThreadPoolExecutor(pool: PTP_POOL?)` API to\nconstruct an executor that will target that thread pool specifically.\nPassing `nil` to that API will use the default pool.\n\n## 📘 Documentation\n\n- [API Documentation](https://swiftpackageindex.com/swiftlang/swift-platform-executors/documentation) - Complete API reference and guides\n\n## 🧰 Release Info\n\nThis repository is released as a package.\n- Release Cadence: Whenever new significant changes have landed on `main`.\n\n## 💡 Contributing\n\nWe welcome contributions to Swift Platform Executors! \n\nTo get started, please read the [Contributing Guide](https://www.swift.org/contributing/).\n\n## 🛠️ Support\n\nIf you have any questions or need help, feel free to reach out by [opening an issue](https://github.com/swiftlang/swift-platform-executors/issues) or\ncontacting the maintainers.\n\n- [GitHub Issues](https://github.com/swiftlang/swift-platform-executors/issues) - Bug reports and feature requests\n- [CODEOWNERS](.github/CODEOWNERS)\n\nThis repo is part of the Platform Steering Group.\n\n## 🔐 Security\n\nIf you discover a security vulnerability, please follow our\n[security policy](https://github.com/swiftlang/swift-platform-executors?tab=security-ov-file)\n for responsible disclosure.\n\n## License\n\nThis project is licensed under the terms of the [LICENSE](LICENSE.txt)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftlang%2Fswift-platform-executors","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fswiftlang%2Fswift-platform-executors","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fswiftlang%2Fswift-platform-executors/lists"}