Asynchronous programming library for MoonBit
moon add moonbitlang/async@0.22.0async fn[X] with_task_group(async (TaskGroup[X]) -> X) -> Xpub(all) suberror BreakFromSpawnLoopimpl Show for TimeoutErrortype Lazy[X]type Mutexpub(all) enum RetryMethod {
Immediate
FixedDelay(Int)
ExponentialDelay(initial~ : Int, factor~ : Double, maximum~ : Int)
}type Task[X]type TaskGroup[X]fn[X] TaskGroup::spawn_loop(self : TaskGroup[X], f : async () -> Unit, no_wait? : Bool, allow_failure? : Bool, retry? : RetryMethod, max_retry? : Int, fatal_error? : (Error) -> Bool) -> Unitpub struct Timer {
duration : Int
// private fields
}#deprecated("`catch` can no longer capture cancellation, and cancellation is no longer represented as an error, so `is_cancellation_error` is now meaningless. Use `with_cancellation_handler` or `is_being_cancelled` instead.")
fn is_cancellation_error(_ : Error) -> Boolasync fn[X] retry(strategy : RetryMethod, max_retry? : Int, fatal_error? : (Error) -> Bool, f : async () -> X) -> X#deprecated("use `handle_cancellation` instead")
async fn[X] with_cancellation_handler(f : async () -> X, handler~ : async () -> Unit) -> Xasync fn[X] with_timeout(time : Int, f : async () -> X, error? : Error) -> Xasync fn[X] with_timeout_opt(time : Int, f : async () -> X) -> X?Install
Download zipAsynchronous programming library for MoonBit