12#if HX_USE_MACROS_WITH_MODULE
13#error Header does not provide macros alone.
41#if (HX_HARDENING_MODE) == HX_HARDENING_MODE_DEBUG
43 ~record_t() { ::memset(
reinterpret_cast<void*
>(
this), 0xefu,
sizeof *
this); }
50 explicit hxtask_queue(int32_t task_queue_size_, int32_t thread_pool_size_)
noexcept;
60 template<
typename callable_t_>
68 template<
typename callable_t_>
99 template<typename callable_t_>
104 template<typename callable_t_>
105 void for_each(callable_t_&& callable_) const noexcept;
111 template<typename callable_t_>
140#define hxtask_queue_lock_ const hxunique_lock lock_(m_mutex_)
144 enum class thread_mode_ : uint8_t {
149 enum class run_level_ : uint32_t {
150 running_ = 0x00c0ffeeu,
151 stopped_ = 0xdeadbeefu
155 static void thread_task_loop_(
hxtask_queue& q_, thread_mode_ mode_)
noexcept;
157 run_level_ m_queue_run_level_;
158 int32_t m_thread_pool_size_;
159 int32_t m_executing_count_;
160 hxthread* m_threads_;
161 mutable hxmutex m_mutex_;
162 hxcondition_variable m_cond_var_new_tasks_;
163 hxcondition_variable m_cond_var_completion_;
165#define hxtask_queue_lock_ ((void)0)
170#include "detail/hxtask_queue.inl"
hxtask_dag_node<max_successors> - A hxtask subclass that implements DAG dependency tracking as a laye...
Definition hxtask_dag_node.hpp:25
record_t - Iterated over by all_of, any_of, erase_if and for_each.
Definition hxtask_queue.hpp:32
hxtask * task
Definition hxtask_queue.hpp:34
const char * label
Definition hxtask_queue.hpp:42
int priority
Definition hxtask_queue.hpp:35
bool operator<(const record_t &x_) const
Orders records by priority so the highest priority sorts last.
Definition hxtask_queue.hpp:39
~record_t()
Definition hxtask_queue.hpp:43
hxtask_queue(int32_t task_queue_size_, int32_t thread_pool_size_) noexcept
Creates a new task queue.
void for_each(callable_t_ &&callable_) const noexcept
Locks the queue and calls callable on each task record.
~hxtask_queue(void)
Waits for all queued and executing tasks to complete before destruction.
hxsize_t erase_if(callable_t_ &&callable_) noexcept
Locks the queue and calls callable on each task.
bool cancel(hxtask *task_) noexcept
Returns true if the task was found and removed.
bool any_of(callable_t_ &&callable_) const noexcept
Locks the queue and calls callable on each task.
void clear(void) noexcept
Removes all queued tasks without executing them.
void wait_for_all(void) noexcept
Execute remaining tasks.
hxsize_t max_size(void) const
Returns the maximum number of tasks that can be queued.
bool all_of(callable_t_ &&callable_) const noexcept
Locks the queue and calls callable on each task.
void enqueue(hxtask *task_, int priority_=0) noexcept
Queues a task for later execution.
hxsize_t size(void) const
Returns the number of queued tasks. Thread-safe.
bool empty(void) const
Returns true when no tasks are queued. Thread-safe.
bool full(void) const
Returns true if the queue capacity has been reached.
hxtask - Pure virtual base class for operations to be performed on a different thread or at a later t...
Definition hxtask.hpp:23
int return_t
The return type of a thread entry point as required by the configured backend.
Definition hxthread.hpp:356
hxvector - Implements std::vector, std::inplace_vector and std::back_insert_iterator with a few thing...
Definition hxvector.hpp:82
#define hxattr_nonnull(...)
hxattr_nonnull - Indicates that a function has args that should not be null.
Definition hxsettings.h:97
#define hxattr_nodiscard
hxattr_nodiscard - Indicates the caller should not discard the return value.
Definition hxsettings.h:89
Pure virtual base class for operations to be performed on a different thread or at a later time.
C++ wrappers for POSIX pthreads or C11 threads.h.
Implements std::vector, std::inplace_vector and std::back_insert_iterator with a few things added and...
Provides core macros, memory management and feature detection.
ptrdiff_t hxsize_t
hxsize_t - A signed size type, same as ssize_t or ptrdiff_t.
Definition libhatchet.h:209