{"id":24504340,"url":"https://github.com/vegardit/haxe-concurrent","last_synced_at":"2026-01-25T09:34:42.841Z","repository":{"id":24051496,"uuid":"100484259","full_name":"vegardit/haxe-concurrent","owner":"vegardit","description":"A haxelib for basic platform-agnostic concurrency support ","archived":false,"fork":false,"pushed_at":"2025-10-18T21:24:39.000Z","size":549,"stargazers_count":85,"open_issues_count":2,"forks_count":12,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-10-18T23:00:09.702Z","etag":null,"topics":["concurrency","executor","hashlink","haxe","haxelib","lock","neko","scheduler","thread","thread-pool"],"latest_commit_sha":null,"homepage":"https://vegardit.github.io/haxe-concurrent/","language":"Haxe","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/vegardit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"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":"2017-08-16T11:57:03.000Z","updated_at":"2025-10-18T21:24:43.000Z","dependencies_parsed_at":"2024-03-18T11:36:32.349Z","dependency_job_id":"e07dd638-b2a5-41dd-837f-d4d772092192","html_url":"https://github.com/vegardit/haxe-concurrent","commit_stats":null,"previous_names":[],"tags_count":24,"template":false,"template_full_name":null,"purl":"pkg:github/vegardit/haxe-concurrent","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fhaxe-concurrent","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fhaxe-concurrent/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fhaxe-concurrent/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fhaxe-concurrent/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vegardit","download_url":"https://codeload.github.com/vegardit/haxe-concurrent/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vegardit%2Fhaxe-concurrent/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28750875,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-25T09:00:19.176Z","status":"ssl_error","status_checked_at":"2026-01-25T09:00:04.131Z","response_time":113,"last_error":"SSL_read: 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":["concurrency","executor","hashlink","haxe","haxelib","lock","neko","scheduler","thread","thread-pool"],"created_at":"2025-01-21T23:23:12.306Z","updated_at":"2026-01-25T09:34:42.835Z","avatar_url":"https://github.com/vegardit.png","language":"Haxe","readme":"# haxe-concurrent - cross-platform concurrency support\n\n[![Build Status](https://github.com/vegardit/haxe-concurrent/workflows/Build/badge.svg \"GitHub Actions\")](https://github.com/vegardit/haxe-concurrent/actions?query=workflow%3A%22Build%22)\n[![Release](https://img.shields.io/github/release/vegardit/haxe-concurrent.svg)](http://lib.haxe.org/p/haxe-concurrent)\n[![License](https://img.shields.io/github/license/vegardit/haxe-concurrent.svg?label=license)](#license)\n[![Contributor Covenant](https://img.shields.io/badge/Contributor%20Covenant-v2.1%20adopted-ff69b4.svg)](CODE_OF_CONDUCT.md)\n\n1. [What is it?](#what-is-it)\n1. [`hx.concurrent.atomic` package](#atomic-package)\n1. [`hx.concurrent.collection` package](#collection-package)\n1. [`hx.concurrent.executor` package](#executor-package)\n1. [`hx.concurrent.event` package](#event-package)\n1. [`hx.concurrent.lock` package](#lock-package)\n1. [`hx.concurrent.thread` package](#thread-package)\n1. [Installation](#installation)\n1. [Using the latest code](#latest)\n1. [License](#license)\n1. [Alternatives](#alternatives)\n\n\n## \u003ca name=\"what-is-it\"\u003e\u003c/a\u003eWhat is it?\n\nA [haxelib](http://lib.haxe.org/documentation/using-haxelib/) that provides some basic platform agnostic concurrency support.\n\nAll classes are located in the package `hx.concurrent` or below.\n\nThe library has been extensively unit tested (over 400 individual test cases) on the targets C++, C#, [Eval](https://haxe.org/blog/eval/), Flash, [HashLink](https://hashlink.haxe.org/),\nJava, JavaScript ([Node.js](https://nodejs.org) and PhantomJS), Lua, [Neko](https://nekovm.org/), [PHP](https://www.php.net/) 7 and [Python](https://www.python.org/) 3.\n\n**Note:**\n- When targeting Flash the option `-swf-version 11.5` (or higher) must be specified, otherwise you will get `Class flash.concurrent::Condition could not be found.`\n- When targeting C# the option `-D net-ver=45` must be specified, otherwise you may get `error CS0234: The type or namespace name 'Volatile' does not exist in the namespace 'System.Threading'. Are you missing an assembly reference?`\n- Multi-threading/locking support in Eval is broken, see some of the unresolved issues:\n  - https://github.com/HaxeFoundation/haxe/issues/8524\n  - https://github.com/HaxeFoundation/haxe/issues/8525\n\n\n### Haxe compatibility\n\n|haxe-concurrent |Haxe           |\n|----------------|---------------|\n|1.0.0 to 1.2.0  |3.2.1 or higher|\n|2.0.0 to 2.1.3  |3.4.2 or higher|\n|3.0.0 or higher |4.0.5 or higher|\n|4.0.0 or higher |4.2.0 or higher|\n\n\n## \u003ca name=\"atomic-package\"\u003e\u003c/a\u003eThe `hx.concurrent.atomic` package\n\nThe [hx.concurrent.atomic](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/atomic) package contains mutable value holder classes that allow for thread.safe manipulation:\n\n- [AtomicBool](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/atomic/AtomicBool.hx)\n- [AtomicInt](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/atomic/AtomicInt.hx)\n- [AtomicValue](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/atomic/AtomicValue.hx)\n\n\n## \u003ca name=\"collection-package\"\u003e\u003c/a\u003eThe `hx.concurrent.collection` package\n\nThe [hx.concurrent.collection](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/collection) package contains thread-safe implementations of different types of collections:\n\n- [CopyOnWriteArray](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/collection/CopyOnWriteArray.hx)\n- [Queue](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/collection/Queue.hx)\n- [SynchronizedArray](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/collection/SynchronizedArray.hx)\n- [SynchronizedLinkedList](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/collection/SynchronizedLinkedList.hx)\n- [SynchronizedMap](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/collection/SynchronizedMap.hx)\n\n\n## \u003ca name=\"executor-package\"\u003e\u003c/a\u003eThe `hx.concurrent.executor` package\n\nThe [hx.concurrent.executor](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/executor) package contains\n[Executor](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/executor/Executor.hx) implementations that allow\nto execute functions concurrently and to schedule tasks for later/repeated execution.\n\nOn platform with the thread support (C++, C#, Eval, HashLink, Neko, Python, Java) threads are used to realize true concurrent execution, on other\nplatforms `haxe.Timer` is used to at least realize async execution.\n\n```haxe\nimport hx.concurrent.executor.Schedule;\nimport hx.concurrent.executor.Executor;\n\nclass Test {\n\n   static function main() {\n      var executor = Executor.create(3);  // \u003c- 3 means to use a thread pool of 3 threads on platforms that support threads\n      // depending on the platform either a thread-based or timer-based implementation is returned\n\n      // define a function to be executed concurrently/async/scheduled (return type can also be Void)\n      var myTask = function():Date {\n         trace(\"Executing...\");\n         return Date.now();\n      }\n\n      // submit 10 tasks each to be executed once asynchronously/concurrently as soon as possible\n      for (i in 0...10) {\n         executor.submit(myTask);\n      }\n\n      executor.submit(myTask, ONCE(2000));            // async one-time execution with a delay of 2 seconds\n      executor.submit(myTask, FIXED_RATE(200));       // repeated async execution every 200ms\n      executor.submit(myTask, FIXED_DELAY(200));      // repeated async execution 200ms after the last execution\n      executor.submit(myTask, HOURLY(30));            // async execution 30min after each full hour\n      executor.submit(myTask, DAILY(3, 30));          // async execution daily at 3:30\n      executor.submit(myTask, WEEKLY(SUNDAY, 3, 30)); // async execution Sundays at 3:30\n\n      // submit a task and keep a reference to it\n      var future = executor.submit(myTask, FIXED_RATE(200));\n\n      // check if a result is already available\n      switch (future.result) {\n         case VALUE(value, time, _): trace('Successfully execution at ${Date.fromTime(time)} with result: $value');\n         case FAILURE(ex, time, _):  trace('Execution failed at ${Date.fromTime(time)} with exception: $ex');\n         case PENDING(_):            trace(\"No result yet...\");\n      }\n\n      // check if the task is scheduled to be executed (again) in the future\n      if (!future.isStopped) {\n         trace('The task is scheduled for further executions with schedule: ${future.schedule}');\n      }\n\n      // cancel any future execution of the task\n      future.cancel();\n   }\n}\n```\n\n\n## \u003ca name=\"event-package\"\u003e\u003c/a\u003eThe `hx.concurrent.event` package\n\nThe [hx.concurrent.event](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/event) package contains classes for type-safe event dispatching.\n\n```haxe\nimport hx.concurrent.event.AsyncEventDispatcher;\nimport hx.concurrent.event.SyncEventDispatcher;\nimport hx.concurrent.Future;\nimport hx.concurrent.executor.Executor;\n\nclass Test {\n\n   static function main() {\n      /**\n       * create a dispatcher that notifies listeners/callbacks synchronously in the current thread\n       */\n      var syncDispatcher = new SyncEventDispatcher\u003cString\u003e(); // events are of type string\n\n      // create event listener\n      var onEvent = function(event:String):Void {\n         trace('Received event: $event');\n      }\n\n      syncDispatcher.subscribe(onEvent);\n\n      // notify all registered listeners synchronously,\n      // meaning this method call blocks until all listeners are finished executing\n      syncDispatcher.fire(\"Hey there\");\n\n      /**\n       * create a dispatcher that notifies listeners asynchronously using an executor\n       */\n      var executor = Executor.create(5); // thread-pool with 5 threads\n      var asyncDispatcher = new AsyncEventDispatcher\u003cString\u003e(executor);\n\n      // create event listener\n      var onAsyncEvent = function(event:String):Void {\n         trace('Received event: $event');\n      }\n\n      // notify all registered listeners asynchronously,\n      // meaning this method call returns immediately\n      asyncDispatcher.fire(\"Hey there\");\n\n      // fire another event and get notified when all listeners where notified\n      var future = asyncDispatcher.fire(\"Boom\");\n\n      asyncDispatcher.subscribe(onAsyncEvent);\n\n      future.onCompletion(result -\u003e {\n         switch(result) {\n            case VALUE(count, _): trace('$count listeners were successfully notified');\n            case FAILURE(ex, _):  trace('Event could not be delivered because of: $ex');\n            case PENDING(_):      trace(\"Nothing is happening\");\n          }\n      });\n   }\n}\n```\n\n\n## \u003ca name=\"lock-package\"\u003e\u003c/a\u003eThe `hx.concurrent.lock` package\n\nThe [hx.concurrent.lock](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/lock) package contains lock implementations for different purposes:\n\n- [RLock](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/lock/RLock.hx) - a reentrant lock\n- [RWLock](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/lock/RWLock.hx) - an upgradeable read-write lock\n- [Semaphore](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/lock/Semaphore.hx)\n\n\n## \u003ca name=\"thread-package\"\u003e\u003c/a\u003eThe `hx.concurrent.thread` package\n\nThe [hx.concurrent.thread](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/thread) package contains\nclasses for platforms supporting threads:\n\n- [ThreadPool](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/thread/ThreadPool.hx) - basic thread-pool implementation supporting C++, C#, HashLink, Neko, Java and Python. For advanced concurrency or cross-platform requirements use [Executor](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/executor/Executor.hx) instead.\n\n    ```haxe\n    import hx.concurrent.thread.*;\n\n    class Test {\n\n       static function main() {\n          var pool = new ThreadPool(4); // 4 concurrent threads\n\n          pool.submit(function(ctx:ThreadContext) {\n             // do some work here\n          });\n\n          pool.awaitCompletion(30 * 1000); // wait 30 seconds for all submitted tasks to be processed\n\n          pool.cancelPendingTasks(); // cancels execution of all currently queued tasks\n\n          // initiate graceful stop of all running threads, i.e. they finish the current tasks they process\n          // execution of all other queued tasks is cancelled\n          pool.stop();\n       }\n    }\n    ```\n\n- [Threads](https://github.com/vegardit/haxe-concurrent/blob/main/src/hx/concurrent/thread/Threads.hx)\n\n\n## \u003ca name=\"installation\"\u003e\u003c/a\u003eInstallation\n\n1. install the library via haxelib using the command:\n    ```\n    haxelib install haxe-concurrent\n    ```\n\n2. use in your Haxe project\n\n   - for [OpenFL](http://www.openfl.org/)/[Lime](https://github.com/openfl/lime) projects add `\u003chaxelib name=\"haxe-concurrent\" /\u003e` to your [project.xml](http://www.openfl.org/documentation/projects/project-files/xml-format/)\n   - for free-style projects add `-lib haxe-concurrent`  to `your *.hxml` file or as command line option when running the [Haxe compiler](http://haxe.org/manual/compiler-usage.html)\n\n\n## \u003ca name=\"latest\"\u003e\u003c/a\u003eUsing the latest code\n\n### Using `haxelib git`\n\n```\nhaxelib git haxe-concurrent https://github.com/vegardit/haxe-concurrent main D:\\haxe-projects\\haxe-concurrent\n```\n\n###  Using Git\n\n1. check-out the main branch\n    ```\n    git clone https://github.com/vegardit/haxe-concurrent --branch main --single-branch D:\\haxe-projects\\haxe-concurrent\n    ```\n\n2. register the development release with Haxe\n    ```\n    haxelib dev haxe-concurrent D:\\haxe-projects\\haxe-concurrent\n    ```\n\n\n## \u003ca name=\"license\"\u003e\u003c/a\u003eLicense\n\nAll files are released under the [Apache License 2.0](LICENSE.txt).\n\nIndividual files contain the following tag instead of the full license text:\n```\nSPDX-License-Identifier: Apache-2.0\n```\n\nThis enables machine processing of license information based on the SPDX License Identifiers that are available here: https://spdx.org/licenses/.\n\n\n## \u003ca name=\"alternatives\"\u003e\u003c/a\u003eAlternatives\n\nOther libraries addressing concurrency/parallelism:\n\n- https://github.com/botsman/hxasync - async/await implementation for Python and JavaScript\n- https://github.com/haxetink/tink_concurrent - abstraction layer over the target-specific concurrency APIs\n- https://github.com/thomasuster/haxe-threadpool (2017) thread pool implementation for C++, Neko, Java, C# and Python\n- https://github.com/Rezmason/Golems (2017)\n- https://github.com/kevinresol/filelock (2016)\n- https://github.com/Blank101/haxe-concurrency (2015)\n- https://github.com/TiVo/activity (2015)\n- https://gist.github.com/hamaluik/80fb81f84ecedbe2a6af (2014) - cross platform API but only uses real threads on C++ and Neko, otherwise single threaded blocking execution\n- https://github.com/zjnue/hxworker (2014)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegardit%2Fhaxe-concurrent","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvegardit%2Fhaxe-concurrent","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvegardit%2Fhaxe-concurrent/lists"}