30 #define _PPL_CONTAINER
32 #if !(defined (_M_X64) || defined (_M_IX86) || defined (_M_ARM) || defined (_M_ARM64))
33 #error ERROR: Concurrency Runtime is supported only on X64, X86, ARM, and ARM64 architectures.
37 #error ERROR: Concurrency Runtime is not supported when compiling /clr.
40 #pragma pack(push,_CRT_PACKING)
42 #pragma warning (disable: 4510 4512 4610) // disable warnings for compiler unable to generate constructor
43 #pragma push_macro("new")
54 template<
typename _Ty,
class _Ax = std::allocator<_Ty> >
64 class _Concurrent_queue_iterator_rep;
95 virtual void _Copy_item(
_Page& _Dst,
size_t _Index,
const void* _Src ) = 0;
148 class _Pop_finalizer;
149 class _Push_finalizer;
161 bool _Pop(
void* _Dest, _Ticket _K, _Concurrent_queue_base& _Base );
166 #pragma warning(push)
167 #pragma warning(disable: 4324)
203 return _Array[
_Index(_K)];
216 template<
typename _C,
typename _Ty,
typename _U>
219 template<
typename _C,
typename _Ty,
typename _U>
255 template<
typename _Container,
typename _Value>
258 template<
typename _Ty,
class _Ax>
friend class ::Concurrency::concurrent_queue;
311 template<
typename _Container,
typename _Value>
317 template<
typename _C,
typename _Ty,
typename _U>
323 template<
typename _C,
typename _Ty,
typename _U>
349 template<
typename _Ty,
class _Ax>
352 template<
typename _Container,
typename _Value>
friend class ::Concurrency::details::_Concurrent_queue_iterator;
380 return static_cast<_Ty*
>(
static_cast<void*
>(&_Pg+1))[_Index];
385 new( &
_Get_ref(_Dst,_Index) ) _Ty(*static_cast<const _Ty*>(_Src));
396 _Destroyer _D(_From);
399 *
static_cast<_Ty*
>(_Dst) =
std::move(_From);
406 _Page *_Pg =
reinterpret_cast<_Page*
>(_My_allocator.allocate( _N ));
415 _My_allocator.deallocate( reinterpret_cast<char*>(_Pg), _N );
541 template<
typename _InputIterator>
545 while (_Begin != _End)
766 template<
typename _Ty,
class _Ax>
768 : _Concurrent_queue_base_v4( sizeof(_Ty) ), _My_allocator(_Al)
791 template<
typename _Ty,
class _Ax>
793 : _Concurrent_queue_base_v4( sizeof(_Ty) ), _My_allocator(_Al)
802 template<
typename _Ty,
class _Ax>
806 _Internal_finish_clear();
813 template<
typename _Ty,
class _Ax>
818 if (!_Internal_pop_if_present(
NULL))
830 #pragma pop_macro("new")
Definition: xtr1common:22
friend class _Concurrent_queue_iterator_rep
Definition: concurrent_queue.h:77
_Value * operator->() const
Definition: concurrent_queue.h:290
_Ax allocator_type
A type that represents the allocator class for the concurrent queue.
Definition: concurrent_queue.h:429
Definition: concurrent_queue.h:81
static const size_t _N_queue
Definition: concurrent_queue.h:183
_CONCRTIMP void _Internal_finish_clear()
~_Destroyer()
Definition: concurrent_queue.h:371
#define NULL
Definition: vcruntime.h:236
_Ty & _My_value
Definition: concurrent_queue.h:362
size_t _Items_per_page
Definition: concurrent_queue.h:88
_CONCRTIMP void _Advance()
Definition: concurrent_queue.h:66
void operator=(const _Concurrent_queue_base_v4 &)
_Concurrent_queue_iterator_base_v4(const _Concurrent_queue_iterator_base_v4 &_I)
Definition: concurrent_queue.h:232
concurrent_queue(const allocator_type &_Al=allocator_type())
Constructs a concurrent queue.
Definition: concurrent_queue.h:472
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
bool operator==(const _Concurrent_queue_iterator< _C, _Ty > &_I, const _Concurrent_queue_iterator< _C, _U > &_J)
Definition: concurrent_queue.h:318
_Ty value_type
A type that represents the data type stored in a concurrent queue.
Definition: concurrent_queue.h:423
const _Ty & const_reference
A type that provides a reference to a const element stored in a concurrent queue for reading and perf...
Definition: concurrent_queue.h:442
virtual void _Copy_item(_Page &_Dst, size_t _Index, const void *_Src)
Definition: concurrent_queue.h:383
virtual void _Move_item(_Page &_Dst, size_t _Index, void *_Src)=0
size_type unsafe_size() const
Returns the number of items in the queue. This method is not concurrency-safe.
Definition: concurrent_queue.h:622
std::ptrdiff_t difference_type
A type that provides the signed distance between two elements in a concurrent queue.
Definition: concurrent_queue.h:454
static size_t _Index(_Ticket _K)
Definition: concurrent_queue.h:186
_CONCRTIMP void _Internal_throw_exception() const
void * align(size_t _Bound, size_t _Size, void *&_Ptr, size_t &_Space) _NOEXCEPT
Definition: memory:1985
_CONCRTIMP void _Internal_push(const void *_Src)
__declspec(align(64)) _Subatomic< _Ticket > _Head_counter
_Ty & _Get_ref(_Page &_Pg, size_t _Index)
Definition: concurrent_queue.h:377
size_t _Mask
Definition: concurrent_queue.h:84
_Concurrent_queue_iterator operator++(int)
Definition: concurrent_queue.h:303
static const size_t _Phi
Definition: concurrent_queue.h:179
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:43
std::size_t size_type
A type that counts the number of elements in a concurrent queue.
Definition: concurrent_queue.h:448
int ptrdiff_t
Definition: vcruntime.h:199
_Concurrent_queue_iterator(const _Concurrent_queue_iterator< _Container, typename _Container::value_type > &_Other)
Definition: concurrent_queue.h:272
Definition: concurrent_queue.h:146
_Destroyer(_Ty &_Value)
Definition: concurrent_queue.h:366
_Concurrent_queue_iterator()
Definition: concurrent_queue.h:266
_Page_allocator_type _My_allocator
Definition: concurrent_queue.h:356
bool try_pop(_Ty &_Dest)
Dequeues an item from the queue if one is available. This method is concurrency-safe.
Definition: concurrent_queue.h:606
_Concurrent_queue_rep * _My_rep
Definition: concurrent_queue.h:72
void _Push(void *_Item, _Ticket _K, _Concurrent_queue_base &_Base, void(_Concurrent_queue_base::*moveOp)(_Concurrent_queue_base_v4::_Page &, size_t, void *))
void clear()
Clears the concurrent queue, destroying any currently enqueued elements. This method is not concurren...
Definition: concurrent_queue.h:814
details::_Concurrent_queue_iterator< concurrent_queue, _Ty > iterator
A type that represents a non-thread-safe iterator over the elements in a concurrent queue...
Definition: concurrent_queue.h:665
virtual _CONCRTIMP ~_Concurrent_queue_base_v4()
_CONCRTIMP void _Assign(const _Concurrent_queue_iterator_base_v4 &)
_Ax::template rebind< char >::other _Page_allocator_type
Definition: concurrent_queue.h:355
virtual void _Deallocate_page(_Page *_Pg)
Definition: concurrent_queue.h:412
allocator_type get_allocator() const
Returns a copy of the allocator used to construct the concurrent queue. This method is concurrency-sa...
Definition: concurrent_queue.h:650
_CONCRTIMP void _Internal_move_push(void *_Src)
_CONCRTIMP _Concurrent_queue_base_v4(size_t _Item_size)
_CONCRTIMP ~_Concurrent_queue_iterator_base_v4()
virtual _Page * _Allocate_page()=0
details::_Concurrent_queue_iterator< concurrent_queue, const _Ty > const_iterator
A type that represents a non-thread-safe const iterator over elements in a concurrent queue...
Definition: concurrent_queue.h:671
size_t _Item_size
Definition: concurrent_queue.h:91
size_t _Ticket
Definition: concurrent_queue.h:60
iterator unsafe_end()
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue...
Definition: concurrent_queue.h:704
unsigned int size_t
Definition: sourceannotations.h:19
void operator=(const _Destroyer &)
_Subatomic< _Concurrent_queue_base::_Page * > _Tail_page
Definition: concurrent_queue.h:154
virtual void _Deallocate_page(_Page *p)=0
bool _Pop(void *_Dest, _Ticket _K, _Concurrent_queue_base &_Base)
virtual void _Move_item(_Page &_Dst, size_t _Index, void *_Src)
Definition: concurrent_queue.h:388
volatile long _Page_mutex_flag
Definition: concurrent_queue.h:157
const_iterator unsafe_end() const
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue...
Definition: concurrent_queue.h:740
concurrent_queue(_InputIterator _Begin, _InputIterator _End)
Constructs a concurrent queue.
Definition: concurrent_queue.h:542
~concurrent_queue()
Destroys the concurrent queue.
Definition: concurrent_queue.h:803
_Micro_queue & _Choose(_Ticket _K)
Definition: concurrent_queue.h:200
_Concurrent_queue_iterator & operator=(const _Concurrent_queue_iterator &_Other)
Definition: concurrent_queue.h:278
iterator unsafe_begin()
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue...
Definition: concurrent_queue.h:686
_CONCRTIMP void _Internal_swap(_Concurrent_queue_base_v4 &other)
virtual void _Assign_and_destroy_item(void *_Dst, _Page &_Src, size_t _Index)=0
_Subatomic< _Ticket > _Head_counter
Definition: concurrent_queue.h:152
Definition: concurrent_queue.h:211
_Concurrent_queue_iterator(const _Concurrent_queue_base &_Queue)
Definition: concurrent_queue.h:261
const_iterator unsafe_begin() const
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue...
Definition: concurrent_queue.h:722
_Value & operator*() const
Definition: concurrent_queue.h:285
friend bool operator==(const _Concurrent_queue_iterator< _C, _Ty > &, const _Concurrent_queue_iterator< _C, _U > &)
Definition: concurrent_queue.h:318
_Concurrent_queue_iterator & operator++()
Definition: concurrent_queue.h:296
_CONCRTIMP bool _Internal_empty() const
Definition: concurrent_queue.h:69
_Concurrent_queue_iterator_rep * _My_rep
Definition: concurrent_queue.h:214
constexpr auto empty(const _Container &_Cont) -> decltype(_Cont.empty())
Definition: xutility:1492
_Concurrent_queue_iterator_base_v4()
Definition: concurrent_queue.h:226
Definition: concurrent_queue.h:173
virtual _Page * _Allocate_page()
Definition: concurrent_queue.h:403
bool empty() const
Tests if the concurrent queue is empty at the moment this method is called. This method is concurrenc...
Definition: concurrent_queue.h:638
_Subatomic< _Concurrent_queue_base::_Page * > _Head_page
Definition: concurrent_queue.h:149
_CONCRTIMP size_t _Internal_size() const
#define _CONCRTIMP
Definition: crtdefs.h:48
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1290
void push(const _Ty &_Src)
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.
Definition: concurrent_queue.h:568
virtual void _Copy_item(_Page &_Dst, size_t _Index, const void *_Src)=0
friend bool operator!=(const _Concurrent_queue_iterator< _C, _Ty > &, const _Concurrent_queue_iterator< _C, _U > &)
Definition: concurrent_queue.h:324
_Subatomic< _Ticket > _Tail_counter
Definition: concurrent_queue.h:155
virtual void _Assign_and_destroy_item(void *_Dst, _Page &_Src, size_t _Index)
Definition: concurrent_queue.h:393
bool operator!=(const _Concurrent_queue_iterator< _C, _Ty > &_I, const _Concurrent_queue_iterator< _C, _U > &_J)
Definition: concurrent_queue.h:324
_Concurrent_queue_base_v4 _Concurrent_queue_base
Definition: concurrent_queue.h:140
_Ty & reference
A type that provides a reference to an element stored in a concurrent queue.
Definition: concurrent_queue.h:435
void push(_Ty &&_Src)
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.
Definition: concurrent_queue.h:583
_In_ int _Value
Definition: setjmp.h:173
friend class _Micro_queue_pop_finalizer
Definition: concurrent_queue.h:76
Definition: concurrent_queue.h:359
_Concurrent_queue_iterator_base_v4 concurrent_queue_iterator_base
Definition: concurrent_queue.h:251
_CONCRTIMP bool _Internal_pop_if_present(void *_Dst)
The concurrent_queue class is a sequence container class that allows first-in, first-out access to it...
Definition: concurrent_queue.h:55
_Page * _Next
Definition: concurrent_queue.h:83
void * _My_item
Definition: concurrent_queue.h:223