Spicy
Public Member Functions | List of all members
hilti::rt::Resumable Class Reference

#include <fiber.h>

Public Member Functions

template<typename Function , typename = std::enable_if_t<std::is_invocable<Function, resumable::Handle*>::value>>
 Resumable (Function f)
 
 Resumable (const Resumable &r)=delete
 
 Resumable (Resumable &&r) noexcept=default
 
Resumableoperator= (const Resumable &other)=delete
 
Resumableoperator= (Resumable &&other) noexcept=default
 
void run ()
 
void resume ()
 
void abort ()
 
resumable::Handlehandle ()
 
bool hasResult () const
 
template<typename Result >
const Resultget () const
 
 operator bool () const
 

Detailed Description

Executor for a function that may yield control back to the caller even before it's finished. The caller can then later resume the function to continue its operation.

Constructor & Destructor Documentation

◆ Resumable()

template<typename Function , typename = std::enable_if_t<std::is_invocable<Function, resumable::Handle*>::value>>
hilti::rt::Resumable::Resumable ( Function  f)
inline

Creates an instance initialized with a function to execute. The function can then be started by calling run().

Parameters
ffunction to be executed

Member Function Documentation

◆ abort()

void Resumable::abort ( )

When a function has yielded, abort its operation without resuming.

◆ get()

template<typename Result >
const Result& hilti::rt::Resumable::get ( ) const
inline

Returns the function's result once it has completed. Must not be called before completion; check with hasResult() first.

◆ handle()

resumable::Handle* hilti::rt::Resumable::handle ( )
inline

Returns a handle to the currently running function.

◆ hasResult()

bool hilti::rt::Resumable::hasResult ( ) const
inline

Returns true if the function has completed orderly and provided a result. If so, get() can be used to retrieve the result.

◆ operator bool()

hilti::rt::Resumable::operator bool ( ) const
inlineexplicit

Returns true if the function has completed.

◆ resume()

void Resumable::resume ( )

When a function has yielded, resumes its operation.

◆ run()

void Resumable::run ( )

Starts execution of the function. This must be called only once.


The documentation for this class was generated from the following files: