Skip to content
HaxeFoundationPublic

About

No description, website, or topics provided.

Resources

Stars

15 stars

Watchers

5 watching

Forks

Repository files navigation

hxcoro

A coroutine library for Haxe, providing asynchronous calls, structured concurrency, and more — across all major Haxe targets.

Hello World

import hxcoro.Coro.*;
import hxcoro.CoroRun;

class Main {
    @:coroutine static function greet():Void {
        trace("Hello…");
        delay(500); // suspend for 500 ms
        trace("…World!");
    }

    static function main() {
        CoroRun.run(_ -> greet());
    }
}

Capabilities

  • Asynchronous calls — write asynchronous code in a straightforward sequential style using @:coroutine methods.
  • Structured concurrency — manage lightweight groups of child tasks with well-defined lifetimes and cancellation semantics.
  • Cancellation — first-class CancellationException support throughout, with suspendCancellable for registering cleanup callbacks.
  • Dispatchers & schedulers — pluggable execution model; ships with TrampolineDispatcher, ThreadPoolDispatcher, and (on C++) LuvDispatcher.
  • Cross-target — works on JS, HL, C++, JVM, Python, PHP, Neko, and Eval.
  • JS Promise integration — CoroRun.promise wraps a coroutine as a js.lib.Promise; CoroRun.await suspends on an existing Promise.

Running the Tests

Tests live in the tests/ directory. Each supported target has its own build file:

haxe --cwd tests build-eval.hxml    # Eval (fastest, no extra tools needed)
haxe --cwd tests build-js.hxml      # JavaScript (requires Node.js)
haxe --cwd tests build-hl.hxml      # HashLink
haxe --cwd tests build-cpp.hxml     # C++
haxe --cwd tests build-jvm.hxml     # JVM
haxe --cwd tests build-python.hxml  # Python
haxe --cwd tests build-php.hxml     # PHP
haxe --cwd tests build-neko.hxml    # Neko

Examples

The examples/ directory contains code that builds on hxcoro but isn't part of its API, such as generators. Copy and adapt it as needed.

About

No description, website, or topics provided.

Resources

Stars

15 stars

Watchers

5 watching

Forks

Releases

Packages

Contributors

Languages