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)
41 #pragma warning (push)
42 #pragma warning (disable: 4510 4512 4610) // disable warnings for compiler unable to generate constructor
57 template <
typename _Derived>
76 template <
typename _Operation_type,
typename _Handler_type >
99 _Operation_type *_Res;
119 while (_Op->_M_status == 0)
139 _Operation_type * _POp_list;
143 while (_M_handler_busy == 1)
148 long _OldVal = _InterlockedExchange(&_M_handler_busy, 1);
152 _POp_list =
reinterpret_cast<_Operation_type *
>(_InterlockedExchangePointer(reinterpret_cast<void * volatile *>(&_M_pPending_operations),
NULL));
158 _OldVal = _InterlockedExchange(&_M_handler_busy, 0);
187 template <
typename _Ty,
typename _Compare=std::less<_Ty>,
typename _Ax = std::allocator<_Ty> >
266 _M_data.reserve(_Init_capacity);
296 template<
typename _InputIterator>
490 void push(
const value_type& _Elem)
590 _M_type(_T),
_M_elem(const_cast<value_type*>(&_E)) {}
592 _M_type(_T),
_M_elem(const_cast<value_type*>(&_E)) {}
641 std::vector<value_type, allocator_type>
_M_data;
653 while (_POp_list !=
NULL)
662 _M_data.push_back(*(_PTmp->
_M_elem));
689 if (_M_mark < _M_size &&
_M_compare(_M_data[0], _M_data[_M_size - 1]))
710 while (_PPop_list !=
NULL)
724 if (_M_mark < _M_size &&
_M_compare(_M_data[0], _M_data[_M_size - 1]))
745 if (_M_mark < _M_size)
757 if (_M_mark == 0 && _M_size > 0)
766 value_type _To_place =
std::move(_M_data[_M_mark]);
769 size_type _Parent = (_Cur_pos - 1) >> 1;
774 _M_data[_Cur_pos] =
std::move(_M_data[_Parent]);
777 }
while( _Cur_pos != 0 );
779 _M_data[_Cur_pos] =
std::move(_To_place);
788 size_type _Cur_pos=0, _Child=1;
791 while (_Child < _M_mark)
794 if (_Child + 1 < _M_mark &&
_M_compare(_M_data[_Child], _M_data[_Child + 1]))
799 if (
_M_compare(_M_data[_Target], _M_data[_M_data.size() - 1]))
804 _M_data[_Cur_pos] =
std::move(_M_data[_Target]);
806 _Child = (_Cur_pos << 1) + 1;
809 _M_data[_Cur_pos] =
std::move(_M_data[_M_data.size() - 1]);
812 if (_M_mark > _M_data.size())
814 _M_mark = _M_data.size();
823 #pragma warning (pop)
directory_iterator end(const directory_iterator &) _NOEXCEPT
Definition: filesystem:1974
value_type * _M_elem
Definition: concurrent_priority_queue.h:584
Definition: concurrent_priority_queue.h:575
std::vector< value_type, allocator_type > _M_data
Definition: concurrent_priority_queue.h:641
allocator_type get_allocator() const
Returns a copy of the allocator used to construct the concurrent priority queue. This method is concu...
Definition: concurrent_priority_queue.h:572
#define NULL
Definition: vcruntime.h:236
An aggregator for collecting operations coming from multiple sources and executing them serially on a...
Definition: concurrent_priority_queue.h:77
~_Aggregator()
Definition: concurrent_priority_queue.h:85
_Ty & reference
A type that represents a reference to an element of the type stored in a concurrent priority queue...
Definition: concurrent_priority_queue.h:202
void swap(concurrent_priority_queue &_Queue)
Swaps the contents of two concurrent priority queues. This method is not concurrency-safe.
Definition: concurrent_priority_queue.h:558
_My_functor_type(concurrent_priority_queue< _Ty, _Compare, _Ax > *_PCpq)
Definition: concurrent_priority_queue.h:601
Definition: concurrent_priority_queue.h:578
Implements busy wait with no backoff
Definition: concrt.h:578
#define _CONCRT_ASSERT(x)
Definition: concrt.h:123
void operator()(_Cpq_operation *_POp_list)
Definition: concurrent_priority_queue.h:602
concurrent_priority_queue & operator=(const concurrent_priority_queue &_Src)
Assigns the contents of another concurrent_priority_queue object to this one. This method is not conc...
Definition: concurrent_priority_queue.h:421
void _Initialize_handler(_Handler_type _Handler)
Definition: concurrent_priority_queue.h:89
concurrent_priority_queue(concurrent_priority_queue &&_Src, const allocator_type &_Al)
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:402
The concurrent_priority_queue class is a container that allows multiple threads to concurrently push ...
Definition: concurrent_priority_queue.h:188
size_t size_type
A type that counts the number of elements in a concurrent priority queue.
Definition: concurrent_priority_queue.h:214
bool try_pop(reference _Elem)
Removes and returns the highest priority element from the queue if the queue is non-empty. This method is concurrency-safe.
Definition: concurrent_priority_queue.h:528
_Ty value_type
A type that represents the data type stored in a concurrent priority queue.
Definition: concurrent_priority_queue.h:196
The Concurrency namespace provides classes and functions that provide access to the Concurrency Runti...
Definition: agents.h:43
Definition: concurrent_priority_queue.h:576
const _Ty & const_reference
A type that represents a const reference to an element of the type stored in a concurrent priority qu...
Definition: concurrent_priority_queue.h:208
void clear()
Erases all elements in the concurrent priority. This method is not concurrency-safe.
Definition: concurrent_priority_queue.h:544
_Cpq_operation(value_type &&_E, _Operation_type _T)
Definition: concurrent_priority_queue.h:591
Definition: concurrent_priority_queue.h:575
std::exception_ptr _M_exception_ptr
Definition: concurrent_priority_queue.h:587
bool _SpinOnce()
Spins for one time quantum,until a maximum spin is reached.
Definition: concrt.h:626
Definition: concurrent_priority_queue.h:576
const directory_iterator & begin(const directory_iterator &_Iter) _NOEXCEPT
Definition: filesystem:1968
_Cpq_operation(_Operation_type _T)
Definition: concurrent_priority_queue.h:593
_BidIt1 _Compare(_BidIt1 _Begin1, _BidIt1 _End1, _BidIt2 _Begin2, _BidIt2 _End2, const _RxTraits &_Traits, regex_constants::syntax_option_type _Sflags)
Definition: regex:4355
_Ax allocator_type
A type that represents the allocator class for the concurrent priority queue.
Definition: concurrent_priority_queue.h:220
char _M_padding1[64-sizeof(::Concurrency::details::_Aggregator< _Cpq_operation, _My_functor_type >)]
Definition: concurrent_priority_queue.h:611
concurrent_priority_queue & operator=(concurrent_priority_queue &&_Src)
Assigns the contents of another concurrent_priority_queue object to this one. This method is not conc...
Definition: concurrent_priority_queue.h:442
concurrent_priority_queue(concurrent_priority_queue &&_Src)
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:373
::Concurrency::details::_Aggregator< _Cpq_operation, _My_functor_type > _M_my_aggregator
Definition: concurrent_priority_queue.h:608
void _M_handle_operations(_Cpq_operation *_POp_list)
Handle a batch of operations pending on the concurrent priority queue. Only one thread can execute th...
Definition: concurrent_priority_queue.h:646
concurrent_priority_queue(const concurrent_priority_queue &_Src)
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:323
concurrent_priority_queue< _Ty, _Compare, _Ax > * _M_PCpq
Definition: concurrent_priority_queue.h:598
volatile long _M_handler_busy
Definition: concurrent_priority_queue.h:131
void _Execute(_Operation_type *_Op)
Place operation in list and either handle list or wait for operation to complete. ...
Definition: concurrent_priority_queue.h:97
size_type size() const
Returns the number of elements in the concurrent priority queue. This method is concurrency-safe.
Definition: concurrent_priority_queue.h:479
_Derived * _M_pNext
Definition: concurrent_priority_queue.h:62
void swap(array< _Ty, _Size > &_Left, array< _Ty, _Size > &_Right) _NOEXCEPT_OP(_NOEXCEPT_OP(_Left.swap(_Right)))
Definition: array:433
volatile size_type _M_size
Definition: concurrent_priority_queue.h:618
concurrent_priority_queue(const allocator_type &_Al=allocator_type())
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:239
_Operation_type _M_type
Definition: concurrent_priority_queue.h:581
const void * _Target(const _XSTD2 type_info &_Info) const _NOEXCEPT
Definition: functional:413
size_type _M_size
Definition: concurrent_priority_queue.h:585
_Aggregator()
Definition: concurrent_priority_queue.h:80
size_type _M_mark
Definition: concurrent_priority_queue.h:614
void * _InterlockedCompareExchangePointer(void *volatile *, void *, void *)
Definition: concurrent_priority_queue.h:575
void push(const value_type &_Elem)
Adds an element to the concurrent priority queue. This method is concurrency-safe.
Definition: concurrent_priority_queue.h:490
Definition: concurrent_priority_queue.h:576
void rethrow_exception(_In_ exception_ptr _Ptr)
Definition: exception:364
void _Heapify()
Merge unsorted elements into heap.
Definition: concurrent_priority_queue.h:755
_Cpq_operation(const_reference _E, _Operation_type _T)
Definition: concurrent_priority_queue.h:589
concurrent_priority_queue(size_type _Init_capacity, const allocator_type &_Al=allocator_type())
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:264
_Handler_type _M_handle_operations
Definition: concurrent_priority_queue.h:134
_Operation_type
Definition: concurrent_priority_queue.h:575
void push(value_type &&_Elem)
Adds an element to the concurrent priority queue. This method is concurrency-safe.
Definition: concurrent_priority_queue.h:507
char _M_padding2[64-sizeof(size_type)-sizeof(_Compare)]
Definition: concurrent_priority_queue.h:624
concurrent_priority_queue(_InputIterator _Begin, _InputIterator _End, const allocator_type &_Al=allocator_type())
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:297
_Aggregated_operation base class
Definition: concurrent_priority_queue.h:58
void _Reheap()
Re-_Heapify by pushing last element down the heap from the root.
Definition: concurrent_priority_queue.h:786
Definition: concurrent_priority_queue.h:575
_Operation_status
Definition: concurrent_priority_queue.h:576
void _Start_handle_operations()
Definition: concurrent_priority_queue.h:137
_Compare _M_compare
Definition: concurrent_priority_queue.h:621
concurrent_priority_queue(const concurrent_priority_queue &_Src, const allocator_type &_Al)
Constructs a concurrent priority queue.
Definition: concurrent_priority_queue.h:349
_My_functor_type()
Definition: concurrent_priority_queue.h:600
constexpr remove_reference< _Ty >::type && move(_Ty &&_Arg) _NOEXCEPT
Definition: type_traits:1290
exception_ptr current_exception() _NOEXCEPT
Definition: exception:359
_Operation_type *volatile _M_pPending_operations
Definition: concurrent_priority_queue.h:128
volatile int _M_status
Definition: concurrent_priority_queue.h:61
_Aggregated_operation()
Definition: concurrent_priority_queue.h:64
bool empty() const
Tests if the concurrent priority queue is empty at the time this method is called. This method is concurrency-safe.
Definition: concurrent_priority_queue.h:463
Definition: concurrent_priority_queue.h:596