Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Public Member Functions | Friends | List of all members
uni20::async::TaskFactory Class Reference

Factory for producing multiple BasicTask ownership claims for one coroutine. More...

#include <async_task_promise.hpp>

Public Member Functions

TaskFactory & operator= (TaskFactory &&other) noexcept
 Move assignment.
 
TaskFactory & operator= (TaskFactory const &)=delete
 
BasicTask take_next ()
 Dispense the next BasicTask from the pool of shared ownership handles.
 
 TaskFactory (TaskFactory &&other) noexcept
 
 TaskFactory (TaskFactory const &)=delete
 
 ~TaskFactory () noexcept
 Destructor returns any unused ownership claims and may destroy the coroutine.
 

Friends

class TaskPromiseBase
 

Detailed Description

Factory for producing multiple BasicTask ownership claims for one coroutine.

This is used when multiple awaiters (e.g., in an all(A, B, C) construct) need to take independent ownership of the same coroutine. The factory pre-allocates all references atomically and ensures that they are handed out exactly once.

Note
This class must only be created while the coroutine is unowned. Attempting to add awaiters after the coroutine is active leads to race conditions and is undefined behavior.

Constructor & Destructor Documentation

◆ TaskFactory() [1/2]

uni20::async::TaskFactory::TaskFactory ( TaskFactory &&  other)
inlinenoexcept

◆ TaskFactory() [2/2]

uni20::async::TaskFactory::TaskFactory ( TaskFactory const &  )
delete

◆ ~TaskFactory()

uni20::async::TaskFactory::~TaskFactory ( )
inlinenoexcept

Destructor returns any unused ownership claims and may destroy the coroutine.

If any BasicTask values were not handed out via take_next(), they are released here. If the coroutine is unowned after release, it will be destroyed.

Member Function Documentation

◆ operator=() [1/2]

TaskFactory & uni20::async::TaskFactory::operator= ( TaskFactory &&  other)
inlinenoexcept

Move assignment.

Parameters
otherSource factory.
Returns
Reference to *this.

◆ operator=() [2/2]

TaskFactory & uni20::async::TaskFactory::operator= ( TaskFactory const &  )
delete

◆ take_next()

BasicTask uni20::async::TaskFactory::take_next ( )
inline

Dispense the next BasicTask from the pool of shared ownership handles.

Precondition
count_ > 0 — there must be remaining tasks to dispense.
Postcondition
One fewer task will be available from this factory.
Returns
A BasicTask that shares ownership of the coroutine.

Friends And Related Symbol Documentation

◆ TaskPromiseBase

friend class TaskPromiseBase
friend

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