17 #ifndef __TBB_concurrent_queue_H 18 #define __TBB_concurrent_queue_H 20 #define __TBB_concurrent_queue_H_include_area 28 namespace strict_ppl {
34 template<
typename T,
typename A = cache_aligned_allocator<T> >
44 void *b =
reinterpret_cast<void*
>(my_allocator.allocate( n ));
52 my_allocator.deallocate( reinterpret_cast<char*>(b), n );
56 new (location) T(*static_cast<const T*>(src));
59 #if __TBB_CPP11_RVALUE_REF_PRESENT 61 new (location) T(
std::move(*static_cast<T*>(const_cast<void*>(src))) );
90 template<
typename InputIterator>
105 #if __TBB_CPP11_RVALUE_REF_PRESENT 136 #if __TBB_CPP11_RVALUE_REF_PRESENT 141 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 142 template<
typename... Arguments>
144 push( T(std::forward<Arguments>( args )...) );
146 #endif //__TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 180 #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT 182 template<
typename InputIterator,
183 typename T =
typename std::iterator_traits<InputIterator>::value_type,
189 template<
typename T,
class A>
195 template<
typename T,
class A>
209 template<
typename T,
class A = cache_aligned_allocator<T> >
230 return (&static_cast<padded_page*>(static_cast<void*>(&p))->
last)[index];
234 new( &get_ref(dst,index) ) T(*static_cast<const T*>(src));
237 #if __TBB_CPP11_RVALUE_REF_PRESENT 239 new( &get_ref(dst,index) ) T(
std::move(*static_cast<T*>(const_cast<void*>(src))) );
248 new( &get_ref(dst,dindex) ) T( get_ref( const_cast<page&>(src), sindex ) );
251 #if __TBB_CPP11_RVALUE_REF_PRESENT 253 new( &get_ref(dst,dindex) ) T(
std::move(get_ref( const_cast<page&>(src), sindex )) );
262 T& from = get_ref(src,index);
268 size_t n =
sizeof(
padded_page) + (items_per_page-1)*
sizeof(T);
269 page *
p =
reinterpret_cast<page*
>(my_allocator.allocate( n ));
276 size_t n =
sizeof(
padded_page) + (items_per_page-1)*
sizeof(T);
277 my_allocator.deallocate( reinterpret_cast<char*>(
p), n );
314 #if __TBB_CPP11_RVALUE_REF_PRESENT 331 this->move_content( src );
338 template<
typename InputIterator>
344 internal_push_if_not_full(&*begin);
355 #if __TBB_CPP11_RVALUE_REF_PRESENT 356 void push( T&& source ) {
358 internal_push_move( &source );
361 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 362 template<
typename... Arguments>
364 push( T(std::forward<Arguments>( args )...) );
371 void pop( T& destination ) {
372 internal_pop( &destination );
375 #if TBB_USE_EXCEPTIONS 386 return internal_push_if_not_full( &source );
389 #if __TBB_CPP11_RVALUE_REF_PRESENT 394 return internal_push_move_if_not_full( &source );
396 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 397 template<
typename... Arguments>
399 return try_push( T(std::forward<Arguments>( args )...) );
408 return internal_pop_if_present( &destination );
429 internal_set_capacity( new_capacity,
sizeof(T) );
451 #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT 453 template<
typename InputIterator,
454 typename T =
typename std::iterator_traits<InputIterator>::value_type,
460 template<
typename T,
class A>
466 template<
typename T,
class A>
477 #undef __TBB_concurrent_queue_H_include_area size_t size_type
Integral type for representing size of the queue.
virtual void move_item(page &dst, size_t index, const void *src) __TBB_override
A allocator_type
Allocator type.
size_type unsafe_size() const
Return the number of items in the queue; thread unsafe.
bool internal_try_pop(void *dst)
Attempt to dequeue item from queue.
bool internal_empty() const
check if the queue is empty; thread safe
void move(tbb_thread &t1, tbb_thread &t2)
virtual void copy_page_item(page &dst, size_t dindex, const page &src, size_t sindex) __TBB_override
bool empty() const
Equivalent to size()<=0.
virtual page * allocate_page() __TBB_override
custom allocator
page_allocator_type my_allocator
concurrent_queue(InputIterator begin, InputIterator end, const allocator_type &a=allocator_type())
[begin,end) constructor
concurrent_bounded_queue(const concurrent_bounded_queue &src, const allocator_type &a=allocator_type())
Copy constructor.
bool try_pop(T &result)
Attempt to dequeue an item from head of queue.
T & get_ref(page &p, size_t index)
virtual void move_page_item(page &dst, size_t dindex, const page &src, size_t sindex) __TBB_override
const_iterator unsafe_end() const
allocator_type get_allocator() const
Return allocator object.
void clear()
Clear the queue. not thread-safe.
virtual void copy_item(page &dst, size_t index, const void *src) __TBB_override
concurrent_queue_base_v3::copy_specifics copy_specifics
Meets requirements of a forward iterator for STL.
concurrent_queue(concurrent_queue &&src, const allocator_type &a)
void emplace(Arguments &&... args)
internal::concurrent_queue_iterator< concurrent_bounded_queue, const T > const_iterator
std::ptrdiff_t size_type
Integral type for representing size of the queue.
void clear()
clear the queue. not thread-safe.
internal::concurrent_queue_iterator< concurrent_queue, T > iterator
void internal_swap(concurrent_queue_base_v3 &src)
swap internal representation
tbb::internal::allocator_rebind< A, char >::type page_allocator_type
Meets requirements of a forward iterator for STL.
T & reference
Reference type.
A high-performance thread-safe blocking concurrent bounded queue.
bool try_push(T &&source)
Move an item at tail of queue if queue is not already full.
allocator_traits< Alloc >::template rebind_alloc< T >::other type
concurrent_bounded_queue(InputIterator begin, InputIterator end, const allocator_type &a=allocator_type())
[begin,end) constructor
base class of concurrent_queue
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
micro_queue< T >::padded_page padded_page
bool try_pop(T &destination)
Attempt to dequeue an item from head of queue.
const T & const_reference
Const reference type.
auto last(Container &c) -> decltype(begin(c))
size_t internal_size() const
Get size of queue; result may be invalid if queue is modified concurrently.
const_iterator unsafe_begin() const
const_iterator unsafe_begin() const
~concurrent_bounded_queue()
Destroy queue.
bool empty() const
Equivalent to size()==0.
A high-performance thread-safe non-blocking concurrent queue.
concurrent_queue_base_v3::padded_page< T > padded_page
concurrent_bounded_queue(const allocator_type &a=allocator_type())
Construct empty queue.
static void move_construct_item(T *location, const void *src)
virtual void assign_and_destroy_item(void *dst, page &src, size_t index) __TBB_override
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp end
Base class for types that should not be copied or assigned.
void push(const T &source)
Enqueue an item at tail of queue.
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
ptrdiff_t difference_type
Difference type for iterator.
Class used to ensure exception-safety of method "pop".
page_allocator_type my_allocator
Allocator type.
void push(const T &source)
Enqueue an item at tail of queue.
virtual void * allocate_block(size_t n) __TBB_override
Allocates a block of size n (bytes)
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d
virtual void deallocate_page(page *p) __TBB_override
custom de-allocator
allocator_type get_allocator() const
return allocator object
internal::concurrent_queue_iterator< concurrent_bounded_queue, T > iterator
size_type size() const
Return number of pushes minus number of pops.
bool try_push(const T &source)
Enqueue an item at tail of queue if queue is not already full.
internal::concurrent_queue_iterator< concurrent_queue, const T > const_iterator
virtual void deallocate_block(void *b, size_t n) __TBB_override
Deallocates block created by allocate_block.
void const char const char int ITT_FORMAT __itt_group_sync p
T & reference
Reference type.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp begin
concurrent_bounded_queue(concurrent_bounded_queue &&src, const allocator_type &a)
void assign(const concurrent_queue_base_v3 &src, item_constructor_t construct_item)
copy or move internal representation
void set_capacity(size_type new_capacity)
Set the capacity.
void internal_push(const void *src, item_constructor_t construct_item)
Enqueue item at tail of queue.
bool try_emplace(Arguments &&... args)
size_type capacity() const
Maximum number of allowed elements.
T value_type
Element type in the queue.
A allocator_type
Allocator type.
std::ptrdiff_t difference_type
Difference type for iterator.
~concurrent_queue()
Destroy queue.
concurrent_queue(const allocator_type &a=allocator_type())
Construct empty queue.
concurrent_queue(const concurrent_queue &src, const allocator_type &a=allocator_type())
Copy constructor.
static void copy_construct_item(T *location, const void *src)
T value_type
Element type in the queue.
tbb::internal::allocator_rebind< A, char >::type page_allocator_type
Allocator type.
const_iterator unsafe_end() const
void pop(T &destination)
Dequeue item from head of queue.
void internal_finish_clear()
free any remaining pages
void emplace(Arguments &&... args)
const T & const_reference
Const reference type.
void const char const char int ITT_FORMAT __itt_group_sync x void const char ITT_FORMAT __itt_group_sync s void ITT_FORMAT __itt_group_sync p void ITT_FORMAT p void ITT_FORMAT p no args __itt_suppress_mode_t unsigned int void size_t ITT_FORMAT d void ITT_FORMAT p void ITT_FORMAT p __itt_model_site __itt_model_site_instance ITT_FORMAT p __itt_model_task __itt_model_task_instance ITT_FORMAT p void ITT_FORMAT p void ITT_FORMAT p void size_t ITT_FORMAT d void ITT_FORMAT p const wchar_t ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s const char ITT_FORMAT s no args void ITT_FORMAT p size_t ITT_FORMAT d no args const wchar_t const wchar_t ITT_FORMAT s __itt_heap_function void size_t int ITT_FORMAT d __itt_heap_function void ITT_FORMAT p __itt_heap_function void void size_t int ITT_FORMAT d no args no args unsigned int ITT_FORMAT u const __itt_domain __itt_id ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain __itt_id ITT_FORMAT p const __itt_domain __itt_id __itt_timestamp __itt_timestamp ITT_FORMAT lu const __itt_domain __itt_id __itt_id __itt_string_handle ITT_FORMAT p const __itt_domain ITT_FORMAT p const __itt_domain __itt_string_handle unsigned long long value