-
Notifications
You must be signed in to change notification settings - Fork 1
runtime
Palamecia edited this page Dec 4, 2022
·
1 revision
This module provides the coroutine scheduling primitives used to execute asynchronous Mint coroutines.
A Runtime.Scheduler is used to spawn coroutines and coordinate their execution. A spawned coroutine can suspend by providing an Runtime.Operation, allowing it to wait asynchronously until the operation completes. Once the operation completes, the scheduler resumes the suspended coroutine.
Spawning a coroutine produces a Runtime.Promise representing its eventual completion. The promise can be used to determine whether the coroutine has completed and to retrieve its result.
The module provides three core abstractions:
- Runtime.Scheduler schedules and executes coroutines.
- Runtime.Operation represents an asynchronous operation on which a coroutine can suspend.
- Runtime.Promise represents the completion and result of a spawned coroutine.
let scheduler = Runtime.Scheduler()
let promise = scheduler.spawn(def [...]() {
return await scheduler.suspend(MyOperation())
})
scheduler.run()
let result = promise.get()
- Introduction
- Variables
-
Built-in-types
- Built-in-types#none
- Built-in-types#null
- Built-in-types#boolean
- Built-in-types#number
- Built-in-types#string
- Built-in-types#regex
- Built-in-types#array
- Built-in-types#hash
- Built-in-types#iterator
- Built-in-types#async_iterator
- Built-in-types#package
- Built-in-types#function
- Built-in-types#coroutine
- Built-in-types#library
- Built-in-types#libobject
- Arithmetic-operations
- Type-casting
- Control-structures
- Function-definition
- User-defined-types
- Work-with-modules