21#include "PTL/Config.hh"
25#if defined(PTL_USE_LOCKS)
40 template <
typename Tp>
68#if defined(PTL_USE_LOCKS)
72 std::atomic<size_type> m_ntasks;
74 std::atomic_bool m_available;
76 std::atomic_uintmax_t* m_all_tasks;
94, m_all_tasks(rhs.m_all_tasks)
102 bool is_avail = m_available.load(std::memory_order_relaxed);
105 return m_available.compare_exchange_strong(is_avail,
false,
106 std::memory_order_relaxed);
116 m_available.store(
true, std::memory_order_release);
124 return m_ntasks.load();
132 return (m_ntasks.load() == 0);
141 assert(m_available.load(std::memory_order_relaxed) ==
false);
143#if defined(PTL_USE_LOCKS)
146 m_task_queue.emplace_front(std::move(task));
155 assert(m_available.load(std::memory_order_relaxed) ==
false);
156 if(m_ntasks.load() == 0)
162#if defined(PTL_USE_LOCKS)
165 _task = std::move(m_task_queue.front());
166 m_task_queue.pop_front();
170#if defined(PTL_USE_LOCKS)
173 _task = std::move(m_task_queue.back());
174 m_task_queue.pop_back();
#define PTL_NO_SANITIZE_THREAD
container_type::size_type size_type
container< task_pointer > container_type
void PushTask(task_pointer &&) PTL_NO_SANITIZE_THREAD
TaskSubQueue & operator=(const TaskSubQueue &)=delete
TaskSubQueue(std::atomic_uintmax_t *_ntasks)
task_pointer PopTask(bool front=true) PTL_NO_SANITIZE_THREAD
std::list< Tp > container
std::shared_ptr< VTask > task_pointer