21 #ifndef __TBB_concurrent_queue_H 22 #define __TBB_concurrent_queue_H 29 namespace strict_ppl {
35 template<
typename T,
typename A = cache_aligned_allocator<T> >
45 void *b =
reinterpret_cast<void*
>(my_allocator.allocate( n ));
53 my_allocator.deallocate( reinterpret_cast<char*>(b), n );
57 new (location) T(*static_cast<const T*>(src));
60 #if __TBB_CPP11_RVALUE_REF_PRESENT 62 new (location) T(
std::move(*static_cast<T*>(const_cast<void*>(src))) );
91 template<
typename InputIterator>
106 #if __TBB_CPP11_RVALUE_REF_PRESENT 137 #if __TBB_CPP11_RVALUE_REF_PRESENT 142 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 143 template<
typename... Arguments>
145 push( T(std::forward<Arguments>( args )...) );
147 #endif //__TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 169 typedef internal::concurrent_queue_iterator<concurrent_queue,T>
iterator;
170 typedef internal::concurrent_queue_iterator<concurrent_queue,const T>
const_iterator;
181 #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT 183 template<
typename InputIterator,
184 typename T =
typename std::iterator_traits<InputIterator>::value_type,
190 template<
typename T,
class A>
196 template<
typename T,
class A>
210 template<
typename T,
class A = cache_aligned_allocator<T> >
212 template<
typename Container,
typename Value>
friend class internal::concurrent_queue_iterator;
231 return (&static_cast<padded_page*>(static_cast<void*>(&p))->
last)[index];
235 new( &get_ref(dst,index) ) T(*static_cast<const T*>(src));
238 #if __TBB_CPP11_RVALUE_REF_PRESENT 240 new( &get_ref(dst,index) ) T(
std::move(*static_cast<T*>(const_cast<void*>(src))) );
249 new( &get_ref(dst,dindex) ) T( get_ref( const_cast<page&>(src), sindex ) );
252 #if __TBB_CPP11_RVALUE_REF_PRESENT 254 new( &get_ref(dst,dindex) ) T(
std::move(get_ref( const_cast<page&>(src), sindex )) );
263 T& from = get_ref(src,index);
269 size_t n =
sizeof(
padded_page) + (items_per_page-1)*
sizeof(T);
270 page *
p =
reinterpret_cast<page*
>(my_allocator.allocate( n ));
277 size_t n =
sizeof(
padded_page) + (items_per_page-1)*
sizeof(T);
278 my_allocator.deallocate( reinterpret_cast<char*>(
p), n );
315 #if __TBB_CPP11_RVALUE_REF_PRESENT 332 this->move_content( src );
339 template<
typename InputIterator>
345 internal_push_if_not_full(&*begin);
356 #if __TBB_CPP11_RVALUE_REF_PRESENT 357 void push( T&& source ) {
359 internal_push_move( &source );
362 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 363 template<
typename... Arguments>
365 push( T(std::forward<Arguments>( args )...) );
372 void pop( T& destination ) {
373 internal_pop( &destination );
376 #if TBB_USE_EXCEPTIONS 387 return internal_push_if_not_full( &source );
390 #if __TBB_CPP11_RVALUE_REF_PRESENT 395 return internal_push_move_if_not_full( &source );
397 #if __TBB_CPP11_VARIADIC_TEMPLATES_PRESENT 398 template<
typename... Arguments>
400 return try_push( T(std::forward<Arguments>( args )...) );
409 return internal_pop_if_present( &destination );
430 internal_set_capacity( new_capacity,
sizeof(T) );
439 typedef internal::concurrent_queue_iterator<concurrent_bounded_queue,T>
iterator;
440 typedef internal::concurrent_queue_iterator<concurrent_bounded_queue,const T>
const_iterator;
452 #if __TBB_CPP17_DEDUCTION_GUIDES_PRESENT 454 template<
typename InputIterator,
455 typename T =
typename std::iterator_traits<InputIterator>::value_type,
461 template<
typename T,
class A>
467 template<
typename T,
class A>
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
static void move_construct_item(T *location, const void *src)
const T & const_reference
Const reference type.
size_t size_type
Integral type for representing size of the queue.
bool try_pop(T &result)
Attempt to dequeue an item from head of queue.
concurrent_bounded_queue(concurrent_bounded_queue &&src, const allocator_type &a)
const_iterator unsafe_end() const
#define __TBB_ASSERT(predicate, comment)
No-op version of __TBB_ASSERT.
bool try_pop(T &destination)
Attempt to dequeue an item from head of queue.
void assign(const concurrent_queue_base_v3 &src, item_constructor_t construct_item)
copy or move internal representation
ptrdiff_t difference_type
Difference type for iterator.
concurrent_queue(InputIterator begin, InputIterator end, const allocator_type &a=allocator_type())
[begin,end) constructor
void clear()
clear the queue. not thread-safe.
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
const_iterator unsafe_begin() const
Class used to ensure exception-safety of method "pop".
size_t internal_size() const
Get size of queue; result may be invalid if queue is modified concurrently.
void clear()
Clear the queue. not thread-safe.
tbb::internal::allocator_rebind< A, char >::type page_allocator_type
Allocator type.
void pop(T &destination)
Dequeue item from head of queue.
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 page * allocate_page() __TBB_override
custom allocator
Meets "allocator" requirements of ISO C++ Standard, Section 20.1.5.
concurrent_queue(concurrent_queue &&src, const allocator_type &a)
concurrent_bounded_queue(const concurrent_bounded_queue &src, const allocator_type &a=allocator_type())
Copy constructor.
internal::concurrent_queue_iterator< concurrent_queue, T > iterator
static void copy_construct_item(T *location, const void *src)
T & get_ref(page &p, size_t index)
T value_type
Element type in the queue.
concurrent_bounded_queue(InputIterator begin, InputIterator end, const allocator_type &a=allocator_type())
[begin,end) constructor
~concurrent_queue()
Destroy queue.
A high-performance thread-safe blocking concurrent bounded queue.
virtual void deallocate_page(page *p) __TBB_override
custom de-allocator
internal::concurrent_queue_iterator< concurrent_bounded_queue, T > iterator
void const char const char int ITT_FORMAT __itt_group_sync p
virtual void copy_item(page &dst, size_t index, const void *src) __TBB_override
virtual void copy_page_item(page &dst, size_t dindex, const page &src, size_t sindex) __TBB_override
concurrent_queue(const allocator_type &a=allocator_type())
Construct empty queue.
const_iterator unsafe_end() const
concurrent_queue_base_v3::copy_specifics copy_specifics
void throw_exception(exception_id eid)
Versionless convenience wrapper for throw_exception_v4()
T & reference
Reference type.
micro_queue< T >::padded_page padded_page
internal::concurrent_queue_iterator< concurrent_bounded_queue, const T > const_iterator
bool internal_empty() const
check if the queue is empty; thread safe
auto last(Container &c) -> decltype(begin(c))
T & reference
Reference type.
friend class internal::concurrent_queue_iterator
void set_capacity(size_type new_capacity)
Set the capacity.
internal::concurrent_queue_iterator< concurrent_queue, const T > const_iterator
size_type capacity() const
Maximum number of allowed elements.
virtual void move_page_item(page &dst, size_t dindex, const page &src, size_t sindex) __TBB_override
size_type size() const
Return number of pushes minus number of pops.
page_allocator_type my_allocator
A allocator_type
Allocator type.
size_type unsafe_size() const
Return the number of items in the queue; thread unsafe.
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
~concurrent_bounded_queue()
Destroy queue.
bool try_emplace(Arguments &&... args)
A allocator_type
Allocator type.
tbb::internal::allocator_rebind< A, char >::type page_allocator_type
void push(const T &source)
Enqueue an item at tail of queue.
allocator_traits< Alloc >::template rebind_alloc< T >::other type
void move(tbb_thread &t1, tbb_thread &t2)
const_iterator unsafe_begin() const
void internal_push(const void *src, item_constructor_t construct_item)
Enqueue item at tail of queue.
bool try_push(T &&source)
Move an item at tail of queue if queue is not already full.
virtual void deallocate_block(void *b, size_t n) __TBB_override
Deallocates block created by allocate_block.
void internal_swap(concurrent_queue_base_v3 &src)
swap internal representation
bool empty() const
Equivalent to size()==0.
bool empty() const
Equivalent to size()<=0.
const T & const_reference
Const reference type.
concurrent_queue(const concurrent_queue &src, const allocator_type &a=allocator_type())
Copy constructor.
bool try_push(const T &source)
Enqueue an item at tail of queue if queue is not already full.
void internal_finish_clear()
free any remaining pages
allocator_type get_allocator() const
Return allocator object.
concurrent_queue_base_v3::padded_page< T > padded_page
void emplace(Arguments &&... args)
concurrent_bounded_queue(const allocator_type &a=allocator_type())
Construct empty queue.
bool internal_try_pop(void *dst)
Attempt to dequeue item from queue.
virtual void * allocate_block(size_t n) __TBB_override
Allocates a block of size n (bytes)
virtual void assign_and_destroy_item(void *dst, page &src, size_t index) __TBB_override
virtual void move_item(page &dst, size_t index, const void *src) __TBB_override
A high-performance thread-safe non-blocking concurrent queue.
T value_type
Element type in the queue.
std::ptrdiff_t difference_type
Difference type for iterator.
void emplace(Arguments &&... args)
page_allocator_type my_allocator
Allocator type.
void push(const T &source)
Enqueue an item at tail of queue.
std::ptrdiff_t size_type
Integral type for representing size of the queue.
allocator_type get_allocator() const
return allocator object