Foundation
Loading...
Searching...
No Matches
Public Member Functions | Public Attributes | List of all members
Foundation::Core::ParallelForAsyncState< Fn > Struct Template Reference

Heap-resident shared state for a non-blocking ThreadPool::ParallelForAsync. More...

#include <ThreadPool.hpp>

Public Member Functions

 ParallelForAsyncState (Fn &&f, size_t t, Allocator *a)
 

Public Attributes

Fn fn
 
size_t total {0}
 
Atomic< size_t > cursor {0}
 
Atomic< size_t > remaining {0}
 
Promise< void > promise
 
Allocatoralloc {nullptr}
 

Detailed Description

template<typename Fn>
struct Foundation::Core::ParallelForAsyncState< Fn >

Heap-resident shared state for a non-blocking ThreadPool::ParallelForAsync.

Unlike the stack-resident ParallelForJob (whose lifetime is bounded by the blocking call), an async parallel-for must outlive the scheduling call: the caller returns immediately with a Future and does not participate. The functor, the shared cursor, the fork-join latch and the Promise all live here; the last worker to drain satisfies the promise and frees the state.

Constructor & Destructor Documentation

◆ ParallelForAsyncState()

template<typename Fn >
Foundation::Core::ParallelForAsyncState< Fn >::ParallelForAsyncState ( Fn &&  f,
size_t  t,
Allocator a 
)
inline

Member Data Documentation

◆ alloc

template<typename Fn >
Allocator* Foundation::Core::ParallelForAsyncState< Fn >::alloc {nullptr}

◆ cursor

template<typename Fn >
Atomic<size_t> Foundation::Core::ParallelForAsyncState< Fn >::cursor {0}

◆ fn

template<typename Fn >
Fn Foundation::Core::ParallelForAsyncState< Fn >::fn

◆ promise

template<typename Fn >
Promise<void> Foundation::Core::ParallelForAsyncState< Fn >::promise

◆ remaining

template<typename Fn >
Atomic<size_t> Foundation::Core::ParallelForAsyncState< Fn >::remaining {0}

◆ total

template<typename Fn >
size_t Foundation::Core::ParallelForAsyncState< Fn >::total {0}

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