Last active
June 4, 2024 13:32
-
-
Save kirkshoop/a47408b4ba09ea9b67b21d3038c4953c to your computer and use it in GitHub Desktop.
WasmComponent - System Context
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:contexts@0.1.0; | |
/// WASI Context is an execution context intended to allow users to | |
/// schedule async functions onto a context provided by the system. | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation scheduling | |
/// It is intended to abstract users from threads and locks | |
/// | |
interface context { | |
use wasi:schedulers@0.1.0.{scheduler}; | |
/// return a scheduler that will be used to add work to this context | |
get_scheduler: func() -> scheduler; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:environments@0.1.0; | |
/// WASI environment provider is a way to access injected services | |
/// intended to allow users to inject schedulers, allocators, | |
/// cancellation notifications into async-functions. | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation | |
/// async-function invocation | |
/// | |
interface environment_provider { | |
use wasi:queries@0.1.0.{query_provider}; | |
/// return a query_provider that will be used to ask for services | |
/// and descriptions of behaviour of the underlying object | |
/// implementation | |
get_env: func() -> query_provider; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:operation-states@0.1.0; | |
/// WASI operation state is the storage for the state used | |
/// by an async-function intended to allow users to store | |
/// the state externally. Users may use reserved storage | |
/// to avoid the dynamic allocation of storage for the | |
/// operation state | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation async | |
/// function invocation | |
/// | |
interface operation_state { | |
/// start the operation | |
/// the receiver is invoked when the operation completes | |
start: func() -> void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:queries@0.1.0; | |
/// WASI query provider is a way to access provided services | |
/// intended to allow users to provide schedulers, allocators, | |
/// cancellation notifications and descriptions of the behaviour | |
/// of the underlying object | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation | |
/// async-function invocation | |
/// | |
interface query_provider { | |
use wasi:queries@0.1.0.{query_provider}; | |
/// return a query_provider that will be used to ask for services | |
/// and descriptions of behaviour of the underlying object | |
/// implementation | |
query: func(??????) -> ???????; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:receivers@0.1.0; | |
/// WASI receiver is the caller-info for an async-function | |
/// intended to allow users to inject services (schedulers, | |
/// allocators, cancellation-notifier), and to inject | |
/// exit-paths for the async-function. | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation async | |
/// function invocation | |
/// | |
interface receiver { | |
/// exit the async-function with a value | |
set_value: func(?????????????) -> void; | |
/// exit the async-function with an error | |
set_error: func(?????????????) -> void; | |
/// exit the async-function early (the | |
/// async-function was cancelled or, in | |
/// some other way, the async functions | |
/// was signalled to exit early) | |
set_stopped: func() -> void; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:schedulers@0.1.0; | |
/// WASI scheduler is a handke to a queue intended to allow users to | |
/// add async functions to the queue. | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation scheduling | |
/// It is intended to abstract users from threads and locks | |
/// | |
interface scheduler { | |
use wasi:senders@0.1.0.{sender}; | |
/// return an async-function (sender) that adds an item | |
/// to this scheduler queue | |
/// the async-function returned will complete from the | |
/// execution context. IOW the user-supplied receiver will | |
/// be invoked on the execution context | |
schedule: func() -> sender; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:senders@0.1.0; | |
/// WASI sender is a packaged async-function intended to | |
/// allow users to create and invoke and compose async | |
/// functions and async algorithms | |
/// | |
/// It is intended to be portable across platforms | |
/// It is intended to support zero-allocation async | |
/// function invocation | |
/// | |
interface sender { | |
use wasi:receivers@0.1.0.{receiver}; | |
use wasi:operation-states@0.1.0.{operation_state}; | |
/// return the operation-state (storage) for an async | |
/// function (sender) that returns an object that contains | |
/// the state needed for the async operation | |
connect: func(receiver) -> operation_state; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package wasi:contexts@0.1.0; | |
world imports { | |
import context; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment