30 #define _PPL_CONTAINER
32 #if !(defined (_M_X64) || defined (_M_IX86) || defined (_M_ARM))
33 #error ERROR: Concurrency Runtime is supported only on X64, X86, and ARM 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
53 template<
typename _Ty,
class _Ax = std::allocator<_Ty> >
63 class _Concurrent_queue_iterator_rep;
147 class _Pop_finalizer;
148 class _Push_finalizer;
160 bool _Pop(
void* _Dest, _Ticket _K, _Concurrent_queue_base& _Base );
165 #pragma warning(push)
166 #pragma warning(disable: 4324)
202 return _Array[
_Index(_K)];
215 template<
typename _C,
typename _Ty,
typename _U>
218 template<
typename _C,
typename _Ty,
typename _U>
254 template<
typename _Container,
typename _Value>
257 template<
typename _Ty,
class _Ax>
friend class ::Concurrency::concurrent_queue;
310 template<
typename _Container,
typename _Value>
316 template<
typename _C,
typename _Ty,
typename _U>
322 template<
typename _C,
typename _Ty,
typename _U>
348 template<
typename _Ty,
class _Ax>
351 template<
typename _Container,
typename _Value>
friend class ::Concurrency::details::_Concurrent_queue_iterator;
379 return static_cast<_Ty*
>(
static_cast<void*
>(&_Pg+1))[_Index];
384 new( &
_Get_ref(_Dst,_Index) ) _Ty(*static_cast<const _Ty*>(_Src));
395 _Destroyer _D(_From);
398 *
static_cast<_Ty*
>(_Dst) =
std::move(_From);
405 _Page *_Pg =
reinterpret_cast<_Page*
>(_My_allocator.allocate( _N ));
414 _My_allocator.deallocate( reinterpret_cast<char*>(_Pg), _N );
540 template<
typename _InputIterator>
544 while (_Begin != _End)
765 template<
typename _Ty,
class _Ax>
767 : _Concurrent_queue_base_v4( sizeof(_Ty) ), _My_allocator(_Al)
790 template<
typename _Ty,
class _Ax>
792 : _Concurrent_queue_base_v4( sizeof(_Ty) ), _My_allocator(_Al)
794 _Internal_swap(_Queue);
801 template<
typename _Ty,
class _Ax>
805 _Internal_finish_clear();
812 template<
typename _Ty,
class _Ax>
817 if (!_Internal_pop_if_present(
NULL))
Definition: xtr1common:34
friend class _Concurrent_queue_iterator_rep
Definition: concurrent_queue.h:76
_Value * operator->() const
Definition: concurrent_queue.h:289
_Ax allocator_type
A type that represents the allocator class for the concurrent queue.
Definition: concurrent_queue.h:428
Definition: concurrent_queue.h:80
static const size_t _N_queue
Definition: concurrent_queue.h:182
_CRTIMP2 void _Concurrent_queue_base_v4::_Internal_swap(_Concurrent_queue_base_v4 &other)
~_Destroyer()
Definition: concurrent_queue.h:370
_Ty & _My_value
Definition: concurrent_queue.h:361
size_t _Items_per_page
Definition: concurrent_queue.h:87
_CRTIMP _In_ int _Value
Definition: setjmp.h:190
_CRTIMP2 void _Internal_throw_exception() const
Definition: concurrent_queue.h:65
void operator=(const _Concurrent_queue_base_v4 &)
_Concurrent_queue_iterator_base_v4(const _Concurrent_queue_iterator_base_v4 &_I)
Definition: concurrent_queue.h:231
concurrent_queue(const allocator_type &_Al=allocator_type())
Constructs a concurrent queue.
Definition: concurrent_queue.h:471
#define _CONCRT_ASSERT(x)
Definition: concrt.h:137
bool operator==(const _Concurrent_queue_iterator< _C, _Ty > &_I, const _Concurrent_queue_iterator< _C, _U > &_J)
Definition: concurrent_queue.h:317
_Ty value_type
A type that represents the data type stored in a concurrent queue.
Definition: concurrent_queue.h:422
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:441
virtual void _Copy_item(_Page &_Dst, size_t _Index, const void *_Src)
Definition: concurrent_queue.h:382
_W64 unsigned int size_t
Definition: crtdefs.h:496
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:621
std::ptrdiff_t difference_type
A type that provides the signed distance between two elements in a concurrent queue.
Definition: concurrent_queue.h:453
static size_t _Index(_Ticket _K)
Definition: concurrent_queue.h:185
void * align(size_t _Bound, size_t _Size, void *&_Ptr, size_t &_Space) _NOEXCEPT
Definition: memory:1951
_N
Definition: wchar.h:1269
__declspec(align(64)) _Subatomic< _Ticket > _Head_counter
_Ty & _Get_ref(_Page &_Pg, size_t _Index)
Definition: concurrent_queue.h:376
_OutIt move(_InIt _First, _InIt _Last, _OutIt _Dest)
Definition: xutility:2447
size_t _Mask
Definition: concurrent_queue.h:83
_Concurrent_queue_iterator operator++(int)
Definition: concurrent_queue.h:302
static const size_t _Phi
Definition: concurrent_queue.h:178
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:42
std::size_t size_type
A type that counts the number of elements in a concurrent queue.
Definition: concurrent_queue.h:447
static void empty(void)
Definition: ivec.h:829
_Concurrent_queue_iterator(const _Concurrent_queue_iterator< _Container, typename _Container::value_type > &_Other)
Definition: concurrent_queue.h:271
_CRTIMP2 void _Internal_push(const void *_Src)
Definition: concurrent_queue.h:145
#define NULL
Definition: crtdbg.h:30
_Destroyer(_Ty &_Value)
Definition: concurrent_queue.h:365
_Concurrent_queue_iterator()
Definition: concurrent_queue.h:265
_Page_allocator_type _My_allocator
Definition: concurrent_queue.h:355
bool try_pop(_Ty &_Dest)
Dequeues an item from the queue if one is available. This method is concurrency-safe.
Definition: concurrent_queue.h:605
_Concurrent_queue_rep * _My_rep
Definition: concurrent_queue.h:71
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:813
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:664
_CRTIMP2 void _Internal_finish_clear()
_Ax::template rebind< char >::other _Page_allocator_type
Definition: concurrent_queue.h:354
virtual void _Deallocate_page(_Page *_Pg)
Definition: concurrent_queue.h:411
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:649
_CRTIMP2 bool _Internal_empty() const
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:670
size_t _Item_size
Definition: concurrent_queue.h:90
_In_ size_t _In_z_ const unsigned char * _Src
Definition: mbstring.h:95
size_t _Ticket
Definition: concurrent_queue.h:59
iterator unsafe_end()
Returns an iterator of type iterator or const_iterator to the end of the concurrent queue...
Definition: concurrent_queue.h:703
_W64 int ptrdiff_t
Definition: crtdefs.h:530
void operator=(const _Destroyer &)
_Subatomic< _Concurrent_queue_base::_Page * > _Tail_page
Definition: concurrent_queue.h:153
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:387
volatile long _Page_mutex_flag
Definition: concurrent_queue.h:156
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:739
concurrent_queue(_InputIterator _Begin, _InputIterator _End)
Constructs a concurrent queue.
Definition: concurrent_queue.h:541
~concurrent_queue()
Destroys the concurrent queue.
Definition: concurrent_queue.h:802
_Micro_queue & _Choose(_Ticket _K)
Definition: concurrent_queue.h:199
_Concurrent_queue_iterator & operator=(const _Concurrent_queue_iterator &_Other)
Definition: concurrent_queue.h:277
iterator unsafe_begin()
Returns an iterator of type iterator or const_iterator to the beginning of the concurrent queue...
Definition: concurrent_queue.h:685
_CRTIMP2 size_t _Internal_size() const
virtual void _Assign_and_destroy_item(void *_Dst, _Page &_Src, size_t _Index)=0
_Subatomic< _Ticket > _Head_counter
Definition: concurrent_queue.h:151
virtual _CRTIMP2 ~_Concurrent_queue_base_v4()
Definition: concurrent_queue.h:210
_Concurrent_queue_iterator(const _Concurrent_queue_base &_Queue)
Definition: concurrent_queue.h:260
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:721
_Value & operator*() const
Definition: concurrent_queue.h:284
friend bool operator==(const _Concurrent_queue_iterator< _C, _Ty > &, const _Concurrent_queue_iterator< _C, _U > &)
Definition: concurrent_queue.h:317
_Concurrent_queue_iterator & operator++()
Definition: concurrent_queue.h:295
Definition: concurrent_queue.h:68
_Concurrent_queue_iterator_rep * _My_rep
Definition: concurrent_queue.h:213
_CRTIMP2 _Concurrent_queue_base_v4(size_t _Item_size)
_Concurrent_queue_iterator_base_v4()
Definition: concurrent_queue.h:225
#define _CRTIMP2
Definition: crtdefs.h:126
Definition: concurrent_queue.h:172
virtual _Page * _Allocate_page()
Definition: concurrent_queue.h:402
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:637
_Subatomic< _Concurrent_queue_base::_Page * > _Head_page
Definition: concurrent_queue.h:148
void push(const _Ty &_Src)
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.
Definition: concurrent_queue.h:567
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:323
_Subatomic< _Ticket > _Tail_counter
Definition: concurrent_queue.h:154
virtual void _Assign_and_destroy_item(void *_Dst, _Page &_Src, size_t _Index)
Definition: concurrent_queue.h:392
bool operator!=(const _Concurrent_queue_iterator< _C, _Ty > &_I, const _Concurrent_queue_iterator< _C, _U > &_J)
Definition: concurrent_queue.h:323
_CRTIMP2 ~_Concurrent_queue_iterator_base_v4()
_Concurrent_queue_base_v4 _Concurrent_queue_base
Definition: concurrent_queue.h:139
_Ty & reference
A type that provides a reference to an element stored in a concurrent queue.
Definition: concurrent_queue.h:434
_CRTIMP2 void _Assign(const _Concurrent_queue_iterator_base_v4 &)
void push(_Ty &&_Src)
Enqueues an item at tail end of the concurrent queue. This method is concurrency-safe.
Definition: concurrent_queue.h:582
_CRTIMP2 void _Internal_move_push(void *_Src)
_CRTIMP2 bool _Internal_pop_if_present(void *_Dst)
friend class _Micro_queue_pop_finalizer
Definition: concurrent_queue.h:75
Definition: concurrent_queue.h:358
_Concurrent_queue_iterator_base_v4 concurrent_queue_iterator_base
Definition: concurrent_queue.h:250
The concurrent_queue class is a sequence container class that allows first-in, first-out access to it...
Definition: concurrent_queue.h:54
_Page * _Next
Definition: concurrent_queue.h:82
void * _My_item
Definition: concurrent_queue.h:222