40#include <snapdev/not_used.h>
41#include <snapdev/is_smart_pointer.h>
65 template<
typename ...>
using void_t = void;
72 template<
typename,
typename,
typename =
void_t<>>
74 :
public std::false_type
78 template<
typename C,
typename R,
typename... A>
80 void_t<decltype(std::declval<C>().valid_workload(std::declval<A>()...))>>
81 :
public std::is_same<decltype(std::declval<C>().valid_workload(std::declval<A>()...)), R>
98 typename std::enable_if<!snapdev::is_shared_ptr<C>::value
103 return item.valid_workload();
117 typename std::enable_if<!snapdev::is_shared_ptr<C>::value
118 && !item_has_predicate<C, bool()>::value
122 snapdev::NOT_USED(item);
139 typename std::enable_if<snapdev::is_shared_ptr<C>::value
140 && item_has_predicate<
typename C::element_type, bool()>::value
144 return item->valid_workload();
158 typename std::enable_if<snapdev::is_shared_ptr<C>::value
159 && !item_has_predicate<
typename C::element_type, bool()>::value
163 snapdev::NOT_USED(item);
270 return std::accumulate(
276 return accum + obj.size();
Create a thread safe FIFO.
std::enable_if< snapdev::is_shared_ptr< C >::value &&!item_has_predicate< typenameC::element_type, bool()>::value, bool >::type validate_item(C const &item)
Validate item.
bool f_broadcast
Whether the done() function called broadcast().
size_t size() const
Return the number of items in the FIFO.
T value_type
The type of value to push and pop from the FIFO.
bool empty() const
Test whether the FIFO is empty.
bool f_done
Whether the FIFO is done.
std::deque< T > items_t
The container type of our items.
void done(bool clear)
Mark the FIFO as done.
bool push_back(T const &v)
Push data on this FIFO.
bool is_done() const
Check whether the FIFO was marked as done.
items_t f_queue
The actual FIFO.
void clear()
Clear the current FIFO.
std::shared_ptr< fifo_type > pointer_t
A smart pointer to the FIFO.
std::enable_if< snapdev::is_shared_ptr< C >::value &&item_has_predicate< typenameC::element_type, bool()>::value, bool >::type validate_item(C const &item)
Validate item.
bool pop_front(T &v, int64_t const usecs)
Retrieve one value from the FIFO.
std::enable_if<!snapdev::is_shared_ptr< C >::value &&item_has_predicate< C, bool()>::value, bool >::type validate_item(C const &item)
Validate item.
fifo< value_type > fifo_type
The type of the FIFO as a typedef.
size_t byte_size() const
Return the total size of the FIFO uses in memory.
std::enable_if<!snapdev::is_shared_ptr< C >::value &&!item_has_predicate< C, bool()>::value, bool >::type validate_item(C const &item)
Validate item.
Lock a mutex in an RAII manner.
A mutex object to ensures atomicity.
bool timed_wait(std::uint64_t const usec)
Wait on a mutex condition with a time limit.
void wait()
Wait on a mutex condition.
void signal()
Signal at least one mutex.
void broadcast()
Broadcast a mutex signal.
Thread Runner and Managers.
Thread Runner and Managers.