§tiro::coroutine
Refers to a coroutine.
#include "tiropp/objects.hpp"
Inherits from handle
§Public Functions
Name | |
---|---|
coroutine(handle h) | |
coroutine(const coroutine & ) =default | |
coroutine(coroutine && ) =default | |
coroutine & | operator=(const coroutine & ) =default |
coroutine & | operator=(coroutine && ) =default |
bool | started() const Returns true if the coroutine started execution. |
bool | completed() const Returns true if the coroutine completed execution (implies started ). |
tiro::result | result() const Returns the coroutine's result (which must have completed). |
template <typename Callback > void | set_callback(Callback && on_complete) Schedules the given callback to be invoked once the coroutine completes. |
void | start() Starts this coroutine's execution. |
§Additional inherited members
Protected Classes inherited from handle
Name | |
---|---|
struct | check_kind_t |
Public Functions inherited from handle
Name | |
---|---|
template <typename T > T | as() const Converts this value to the target type. |
template <typename T > T | as() Converts this value to the target type. |
handle(tiro_vm_t raw_vm) Constructs a new handle instance. | |
handle(const handle & other) Constructs a new handle and initialize is it with the same value as other . | |
handle(handle && other) =default Move constructs a handle. | |
~handle() =default | |
bool | valid() const Returns true if this handle points to an object (i.e. it was not moved from). |
value_kind | kind() const Returns the kind of the value currently held by this handle. |
template <typename T > bool | is() const Returns true if this value is of the target type. |
type | type_of() const Returns the type of the value currently held by this handle. |
string | to_string() const Returns a string that represents the current value. |
tiro_vm_t | raw_vm() const Returns the raw vm instance associated with this handle. |
tiro_handle_t | raw_handle() const Returns the raw handle instance (nullptr for invalid handles). |
Protected Functions inherited from handle
Name | |
---|---|
handle(check_kind_t , handle && other, value_kind expected) |
Protected Attributes inherited from handle
Name | |
---|---|
constexpr check_kind_t | check_kind |
§Public Functions Documentation
§function coroutine
inline explicit coroutine(handle h)
§function coroutine
coroutine(const coroutine &) =default
§function coroutine
coroutine(coroutine &&) =default
§function operator=
coroutine & operator=(const coroutine &) =default
§function operator=
coroutine & operator=(coroutine &&) =default
§function started
inline bool started() const
Returns true if the coroutine started execution.
§function completed
inline bool completed() const
Returns true if the coroutine completed execution (implies started
).
§function result
inline tiro::result result() const
Returns the coroutine's result (which must have completed).
If the coroutine terminated with an uncaught panic, the result will hold an error.
§function set_callback
template <typename Callback >inline void set_callback(Callback && on_complete)
Schedules the given callback to be invoked once the coroutine completes.
There can only be one callback associated with a coroutine.
on_complete
will be invoked when the coroutine completes its execution. A coroutine completes when the outermost function returns normally or if an uncaught panic is thrown from that function. The callback receives a handle to the completed coroutine, which can be inspected in order to retrieve the coroutine's result. It will not be invoked if the virtual machine shuts down before the coroutine has completed.
Note: all callback invocations happen from within one of the vm.run*
method.
§function start
inline void start()
Starts this coroutine's execution.
The coroutine's function will be invoked from within a call to a vm.run*
method.
Updated on 2022-02-27 at 21:17:13 +0100