§tiro::async_frame
Represents the call frame of a asynchronous function call. More...
#include "tiropp/functions.hpp"
§Public Functions
Name | |
---|---|
async_frame(tiro_vm_t raw_vm, tiro_async_frame_t raw_frame) | |
async_frame(async_frame && ) =delete | |
async_frame & | operator=(async_frame && ) =delete |
size_t | arg_count() const Returns the number of arguments passed to this function call. |
handle | arg(size_t index) const Returns the argument at the given index ( 0 <= index < argc ). |
handle | closure() const Returns the closure value referenced by this function (if any). |
void | return_value(const handle & value) Sets the return value for this function call frame to the given value . |
void | panic_msg(std::string_view message) Signals a panic from this function call frame using the given message. |
async_token | token() const Returns a token for resuming an async function call after yielding. |
void | yield() Yields from an async function call, pausing the current coroutine until it is resumed via an async frame token. |
tiro_vm_t | raw_vm() const |
tiro_async_frame_t | raw_frame() const |
§Detailed Description
class tiro::async_frame;
Represents the call frame of a asynchronous function call.
References to sync_frames are only valid from within the surrounding function call.
§Public Functions Documentation
§function async_frame
inline async_frame(tiro_vm_t raw_vm,tiro_async_frame_t raw_frame)
§function async_frame
async_frame(async_frame &&) =delete
§function operator=
async_frame & operator=(async_frame &&) =delete
§function arg_count
inline size_t arg_count() const
Returns the number of arguments passed to this function call.
§function arg
inline handle arg(size_t index) const
Returns the argument at the given index (0 <= index < argc
).
§function closure
inline handle closure() const
Returns the closure value referenced by this function (if any).
§function return_value
inline void return_value(const handle & value)
Sets the return value for this function call frame to the given value
.
This function can be used to signal an immediate return without yielding.
§function panic_msg
inline void panic_msg(std::string_view message)
Signals a panic from this function call frame using the given message.
This function can be used to signal an immediate panic without yielding.
§function token
inline async_token token() const
Returns a token for resuming an async function call after yielding.
Yielding from an async function call must be implemented by
- acquiring an async token and storing it somewhere
- scheduling some asynchronous operation
- calling
[yield()](/docs/api/classes/classtiro_1_1async__frame#function-yield)
on this frame and returning from the native function call After the async operation has completed, the coroutine may be resumed by callingtoken.return_value
ortoken.panic_msg
to provide a function result.
§function yield
inline void yield()
Yields from an async function call, pausing the current coroutine until it is resumed via an async frame token.
The native function should return immediately after calling this function.
§function raw_vm
inline tiro_vm_t raw_vm() const
§function raw_frame
inline tiro_async_frame_t raw_frame() const
Updated on 2022-02-27 at 21:17:13 +0100