Wildmeshing Toolkit
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Member Functions | Private Attributes | List of all members
wmtk::threading::task_group Class Reference

Classes

class  task_job
 A task of this group, queued on the pool. Move-only tasks are fine. More...
 

Public Member Functions

 task_group (const task_group &)=delete
 
task_group & operator= (const task_group &)=delete
 
template<typename F >
void run (F &&f)
 
template<typename F >
bool try_run (F &&f)
 As run(), but only on a worker of the pool that is idle right now. Returns false, having run nothing, if there is none; it never starts a thread.
 
void wait ()
 

Private Member Functions

void record (std::exception_ptr e)
 
void finish_one ()
 

Private Attributes

std::mutex m_mutex
 
std::condition_variable m_done
 
size_t m_pending = 0
 
std::exception_ptr m_eptr
 

Member Function Documentation

◆ try_run()

template<typename F >
bool wmtk::threading::task_group::try_run ( F &&  f)
inline

As run(), but only on a worker of the pool that is idle right now. Returns false, having run nothing, if there is none; it never starts a thread.

For optional help: work the caller would do alone anyway, split up only if threads are sitting idle, where starting a thread for it would cost more than the split saves. Call wait() either way. See Envelope::is_outside() for the use it was written for.


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