Agents 0.0.2
Edge AI Agents SDK
Loading...
Searching...
No Matches
agents::Task< T > Class Template Reference

Standard C++20 coroutine-based Task implementation (no external deps) More...

#include <coroutine_utils.h>

Classes

struct  promise_type
 Promise type for Task. More...
 

Public Types

using handle_type = std::coroutine_handle<promise_type>
 Handle type for Task.
 

Public Member Functions

 Task () noexcept
 Constructor with no handle.
 
 Task (handle_type h)
 Constructor with handle.
 
 Task (Task &&other) noexcept
 Constructor with other Task.
 
Taskoperator= (Task &&other) noexcept
 Operator= for Task.
 
 Task (const Task &)=delete
 
Taskoperator= (const Task &)=delete
 
bool valid () const noexcept
 Valid for Task.
 
bool await_ready () const noexcept
 Await ready for Task.
 
void await_suspend (std::coroutine_handle<> awaiting)
 Await suspend for Task.
 
await_resume ()
 Await resume for Task.
 
get_sync ()
 Synchronously wait and get the value (used by blockingWait)
 

Detailed Description

template<typename T>
class agents::Task< T >

Standard C++20 coroutine-based Task implementation (no external deps)

Template Parameters
TThe result type of the task
Examples
coroutine_example.cpp, multimodal_example.cpp, robotics_object_detection_demo.cpp, simple_agent.cpp, and streaming_chat.cpp.

Constructor & Destructor Documentation

◆ Task() [1/2]

template<typename T>
agents::Task< T >::Task ( handle_type h)
inlineexplicit

Constructor with handle.

Parameters
hThe handle to use

◆ Task() [2/2]

template<typename T>
agents::Task< T >::Task ( Task< T > && other)
inlinenoexcept

Constructor with other Task.

Parameters
otherThe other Task to use

Member Function Documentation

◆ await_ready()

template<typename T>
bool agents::Task< T >::await_ready ( ) const
inlinenoexcept

Await ready for Task.

Returns
Whether the Task is ready

◆ await_resume()

template<typename T>
T agents::Task< T >::await_resume ( )
inline

Await resume for Task.

Returns
The awaited result if T is not void.

◆ await_suspend()

template<typename T>
void agents::Task< T >::await_suspend ( std::coroutine_handle<> awaiting)
inline

Await suspend for Task.

Parameters
awaitingThe awaiting coroutine handle

◆ get_sync()

template<typename T>
T agents::Task< T >::get_sync ( )
inline

Synchronously wait and get the value (used by blockingWait)

Returns
The result of the Task

◆ operator=()

template<typename T>
Task & agents::Task< T >::operator= ( Task< T > && other)
inlinenoexcept

Operator= for Task.

Parameters
otherThe other Task to use
Returns
The Task

◆ valid()

template<typename T>
bool agents::Task< T >::valid ( ) const
inlinenoexcept

Valid for Task.

Returns
Whether the Task is valid