C/C++ API Reference
Loading...
Searching...
No Matches
Dynamic allocation

Oveview

Heap allocate space for tasks or functions with pw::Allocator

Functions

template<typename Pendable >
Taskpw::async2::AllocateTask (pw::allocator::Allocator &allocator, Pendable &&pendable)
 
template<typename Pendable , typename... Args>
Taskpw::async2::AllocateTask (pw::allocator::Allocator &allocator, Args &&... args)
 
template<typename Func >
void pw::async2::EnqueueHeapFunc (Dispatcher &dispatcher, Func &&func)
 

Function Documentation

◆ AllocateTask() [1/2]

template<typename Pendable , typename... Args>
Task * pw::async2::AllocateTask ( pw::allocator::Allocator allocator,
Args &&...  args 
)

Creates a Task by dynamically allocating Task memory from allocator.

Returns nullptr on allocation failure. Pendable must have a Poll<> Pend(Context&) method. allocator must outlive the resulting Task.

◆ AllocateTask() [2/2]

template<typename Pendable >
Task * pw::async2::AllocateTask ( pw::allocator::Allocator allocator,
Pendable &&  pendable 
)

Creates a Task by dynamically allocating Task memory from allocator.

Returns nullptr on allocation failure. Pendable must have a Poll<> Pend(Context&) method. allocator must outlive the resulting Task.

◆ EnqueueHeapFunc()

template<typename Func >
void pw::async2::EnqueueHeapFunc ( Dispatcher dispatcher,
Func &&  func 
)

Heap-allocates space for func and enqueues it to run on dispatcher.

func must be a no-argument callable that returns void.

This function requires heap allocation using new be available.