<
classType,
classContainer,
classTraits>
153 template<
classType,
classContainer>
156 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
159 template<
classType,
classContainer,
classTraits>
162 template<
classType,
classContainer,
classTraits>
214 template<
classType,
classContainer = deque<Type>,
215 classTraits = CSyncQueue_DefaultTraits >
224 typedef typenameContainer::size_type
TSize;
628 template<
classType,
classContainer,
classTraits>
643 #ifdef NCBI_COMPILER_WORKSHOP 648 typenameTNativeConstIter::iterator_category,
708typename
TQueue::TNativeIter, Traits>;
711typename TQueue::TNativeConstIter, Traits>;
725template <class Type, class Container, class Traits>
744 #ifdef NCBI_COMPILER_WORKSHOP 749 typenameTNativeIter::iterator_category,
816 template<
classType,
classNotType>
821 template<
classType>
829 template<
classType,
classContainer>
847 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
862 typedef typenameTNativeIterator::difference_type
TDiff;
864 typedef typenameTNativeIterator::reference
TRef;
896 TPtroperator-> (
void)
const;
909 voidInvalidate(
void);
916 voidCheckValid(
void)
const;
920 voidCheckMatched(
const TThisType& other)
const;
939TNativeIterator x_GetBase()
const;
1001 virtual const char* GetErrCodeString(
void)
const override;
1014 template<
classKey,
1018:
public set<Key, Compare, Allocator>
1026{ TBaseType::insert(elem); }
1027 typenameTBaseType::const_reference
front()
const 1028{
return*TBaseType::begin(); }
1030{ TBaseType::erase(TBaseType::begin()); }
1041 template<
classKey,
1045:
public multiset<Key, Compare, Allocator>
1054TBaseType::insert(std::upper_bound(TBaseType::begin(),
1057TBaseType::key_comp()), elem);
1059 typenameTBaseType::const_reference
front()
const 1060{
return*TBaseType::begin(); }
1062{ TBaseType::erase(TBaseType::begin()); }
1066TBaseType::erase(iter);
1073TBaseType::erase(left, right);
1087 template<
class Type,
1088 classContainer = vector<Type>,
1089 class Compare= less<typename Container::value_type> >
1091:
publicpriority_queue<Type, Container, Compare>
1094 typedefpriority_queue<Type, Container, Compare>
TBaseType;
1107 typenameTBaseType::const_reference
front()
const 1108{
returnTBaseType::top(); }
1110{ TBaseType::pop(); }
1127 "Cannot obtain necessary queue state within a given timeout.");
1135 "The queue has reached its size limit. " 1136 "Cannot push to it anymore.");
1144 "The queue is empty. Can't pop from it any value.");
1153 template<
classType,
classContainer,
classTraits>
1175 if(!Lock(pqueue, timeout)) {
1226 template<
classType,
classContainer,
classTraits>
1230m_MaxSize(max_size),
1238 if(max_size == 0) {
1240 "Maximum size of the queue must be greater than zero");
1245Traits::CSyncQueue_Traits_Must_Be_Inherited_From_CSyncQueue_DefaultTraits();
1249 template<
classType,
classContainer,
classTraits>
1261 template<
classType,
classContainer,
classTraits>
1270 template<
classType,
classContainer,
classTraits>
1278 template<
classType,
classContainer,
classTraits>
1282 returnm_Size >= m_MaxSize;
1286 template<
classType,
classContainer,
classTraits>
1291 if( !m_TrigLock.TryWait(
CTimeout(*timeout)) ) {
1303 template<
classType,
classContainer,
classTraits>
1307 if(!IsFull() && m_CntWaitNotFull.Get() > 0) {
1308m_TrigNotFull.Post();
1310 if(!IsEmpty() && m_CntWaitNotEmpty.Get() > 0) {
1311m_TrigNotEmpty.Post();
1318 template<
classType,
classContainer,
classTraits>
1327 boolis_success =
false;
1328 if(
this< &other_obj) {
1329is_success = my_lock->
Lock(
this) && other_lock->
Lock(&other_obj);
1332is_success = other_lock->
Lock(&other_obj) && my_lock->
Lock(
this);
1341 template<
classType,
classContainer,
classTraits>
1347TCheckFunc func_to_check,
1350TErrorThrower throw_error)
1354unique_ptr<CTimeSpan> real_timeout;
1357real_timeout.reset(
new CTimeSpan(*full_tmo));
1359 #if defined(NCBI_THREADS) 1360 else if(!Traits::IsUsedConcurrently()) {
1363real_timeout.reset(
new CTimeSpan(0.0));
1368real_timeout.reset(
new CTimeSpan(0.0));
1372 if(real_timeout.get()) {
1375 if(!lock->
Lock(
this, service_tmo)) {
1379 while( (this->*func_to_check)() ) {
1396 if( !is_success ) {
1405 if(!lock->
Lock(
this, &tmo)) {
1413lock->
Lock(
this, service_tmo);
1414 while( (this->*func_to_check)() ) {
1423lock->
Lock(
this);
1429 template<
classType,
classContainer,
classTraits>
1437x_LockAndWait(lock, full_tmo, service_tmo, &TThisType::IsFull,
1442 template<
classType,
classContainer,
classTraits>
1450x_LockAndWait(lock, full_tmo, service_tmo, &TThisType::IsEmpty,
1455 template<
classType,
classContainer,
classTraits>
1460 if(x_IsGuarded()) {
1464 if(!
x_Lock(timeout)) {
1478 template<
classType,
classContainer,
classTraits>
1485 if(0 == m_LockCount) {
1494 template<
classType,
classContainer,
classTraits>
1505 template<
classType,
classContainer,
classTraits>
1514m_Store.push_back(elem);
1519 template<
classType,
classContainer,
classTraits>
1529 TValueelem = m_Store.front();
1530m_Store.pop_front();
1536 template<
classType,
classContainer,
classTraits>
1545 template<
classType,
classContainer,
classTraits>
1553 if( !x_IsGuarded() ) {
1554x_LockAndWaitWhileFull(&lock, full_tmo, service_tmo);
1557x_Push_NonBlocking(elem);
1561 template<
classType,
classContainer,
classTraits>
1566Push(elem, timeout, timeout);
1570 template<
classType,
classContainer,
classTraits>
1578 if( !x_IsGuarded() ) {
1579x_LockAndWaitWhileEmpty(&lock, full_tmo, service_tmo);
1582 returnx_Pop_NonBlocking();
1586 template<
classType,
classContainer,
classTraits>
1591 returnPop(timeout, timeout);
1595 template<
classType,
classContainer,
classTraits>
1601 if( !x_IsGuarded() ) {
1602 if(!lock.
Lock(
this, timeout)) {
1607x_Clear_NonBlocking();
1611 template<
classType,
classContainer,
classTraits>
1615 if(
this!= other) {
1621 if( x_IsGuarded() ) {
1623 if(!other_lock.
Lock(other)) {
1630 "Cannot copy queue to another queue locked with " 1631 "access guardian");
1634x_DoubleLock(&my_lock, &other_lock, *other);
1639 "Queue copy cannot be done due to the lack of " 1640 "room in the destination queue.");
1643 copy(m_Store.begin(), m_Store.end(), back_inserter(other->
m_Store));
1644other->
m_Size+= m_Size;
1649 template<
classType,
classContainer,
classTraits>
1654 returnm_Store.begin();
1658 template<
classType,
classContainer,
classTraits>
1663 returnm_Store.begin();
1667 template<
classType,
classContainer,
classTraits>
1672 returnm_Store.end();
1676 template<
classType,
classContainer,
classTraits>
1681 returnm_Store.end();
1685 template<
classType,
classContainer,
classTraits>
1696 template<
classType,
classContainer,
classTraits>
1706 while(srch_iter != m_Store.end() && srch_iter != to_iter) {
1711 if(to_iter != srch_iter) {
1713 "The beginning of interval must be less or equal " 1714 "to the end of interval.");
1717 TNativeIterres = m_Store.erase(from_iter, to_iter);
1727 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1740 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1745m_Guard->x_RemoveIter(
this);
1749 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1759 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1763: m_Guard(other.m_Guard),
1764m_Iter (other.m_Iter),
1765m_Valid(other.m_Valid)
1772 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1779m_Guard->x_RemoveIter(
this);
1786m_Guard->x_AddIter(
this);
1792 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1796m_Guard->x_RemoveIter(
this);
1799m_Iter = TNativeIterator();
1803 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1808 if(m_Guard != guard) {
1810 "Cannot work with iterators from another access guards.");
1814 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1817TNativeIterator, Traits>::CheckValid(
void)
const 1821 "Iterator can't be used after " 1822 "destroying related access guard.");
1827 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1832 if(m_Guard != other.
m_Guard) {
1834 "Cannot compare iterators from different queue guards.");
1839 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1848 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1860 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1873 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1885 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1898 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1911 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1924 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1938 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1948 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1962 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1970CheckMatched(other);
1972 returnm_Iter - other.
m_Iter;
1977 template<
class Type,
classContainer,
1978 classTNativeIterL,
classTNativeIterR,
classTraits>
1988 returnTConstIterator(left) - TConstIterator(right);
1992 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
1996TNativeIterator, Traits>::operator* (void)
const 2004 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2008TNativeIterator, Traits>::operator-> (void)
const 2012 returnm_Iter.operator->();
2016 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2028 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2033CheckMatched(other);
2035 returnm_Iter == other.
m_Iter;
2039 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2044 return!(*
this== other);
2048 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2053CheckMatched(other);
2055 returnm_Iter < other.
m_Iter;
2059 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2064 returnother < *
this;
2068 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2073 return!(other < *
this);
2077 template<
classType,
classContainer,
classTNativeIterator,
classTraits>
2082 return!(*
this< other);
2088 template<
class Type,
classContainer,
2089 classTNativeIterL,
classTNativeIterR,
classTraits>
2092TNativeIterL, Traits>& left,
2094TNativeIterR, Traits>& right)
2100 returnTConstIterator(left) == TConstIterator(right);
2104 template<
class Type,
classContainer,
2105 classTNativeIterL,
classTNativeIterR,
classTraits>
2108TNativeIterL, Traits>& left,
2110TNativeIterR, Traits>& right)
2112 return!(left == right);
2116 template<
class Type,
classContainer,
2117 classTNativeIterL,
classTNativeIterR,
classTraits>
2120TNativeIterL, Traits>& left,
2122TNativeIterR, Traits>& right)
2128 returnTConstIterator(left) < TConstIterator(right);
2132 template<
class Type,
classContainer,
2133 classTNativeIterL,
classTNativeIterR,
classTraits>
2136TNativeIterL, Traits>& left,
2138TNativeIterR, Traits>& right)
2140 returnright < left;
2144 template<
class Type,
classContainer,
2145 classTNativeIterL,
classTNativeIterR,
classTraits>
2148TNativeIterL, Traits>& left,
2150TNativeIterR, Traits>& right)
2152 return!(right < left);
2156 template<
class Type,
classContainer,
2157 classTNativeIterL,
classTNativeIterR,
classTraits>
2160TNativeIterL, Traits>& left,
2162TNativeIterR, Traits>& right)
2164 return!(left < right);
2171 template<
classType,
classContainer,
classTraits>
2175: m_Queue(queue_to_guard)
2181 template<
classType,
classContainer,
classTraits>
2184Traits>::~CSyncQueue_ConstAccessGuard()
2188(*it)->Invalidate();
2195 template<
classType,
classContainer,
classTraits>
2200m_Iters.push_back(iter);
2204 template<
classType,
classContainer,
classTraits>
2209m_Iters.remove(iter);
2213 template<
classType,
classContainer,
classTraits>
2222 template<
classType,
classContainer,
classTraits>
2231 template<
classType,
classContainer,
classTraits>
2240 template<
classType,
classContainer,
classTraits>
2253 template<
classType,
classContainer,
classTraits>
2265 template<
classType,
classContainer,
classTraits>
2273 template<
classType,
classContainer,
classTraits>
2282 template<
classType,
classContainer,
classTraits>
2292 template<
classType,
classContainer,
classTraits>
2306 template<
classType,
classContainer,
classTraits>
2315 template<
classType,
classContainer,
classTraits>
2324 template<
classType,
classContainer,
classTraits>
2333 template<
classType,
classContainer,
classTraits>
@ eEmpty
no filtering at all.
CAtomicCounter_WithAutoInit â.
Exception object used throughout all CSyncQueue classes.
@ eTimeout
Cannot push or pop within the given timeout.
@ eIterNotValid
Iterator belongs to an already destroyed access guardian.
@ eNoRoom
An attempt to push element to an already full queue while the latter is locked by an access guardian.
@ eWrongInterval
An attempt to specify the interval with iterators when "from" iterator is greater than "to" iterator.
@ eMismatchedIters
An attempt to subtract or compare iterators from different access guardians.
@ eWrongGuardIter
An attempt to erase element via iterator that belongs to another access guardian.
@ eEmpty
An attempt to pop element from an already empty queue while the latter is locked by an access guardia...
@ eWrongMaxSize
Maximum size given is equal to zero.
NCBI_EXCEPTION_DEFAULT(CSyncQueueException, CException)
Access guard to non-constant CSyncQueue.
TRevIterator RBegin(void)
Get reverse iterator pointing to the tail of the queue.
CSyncQueue_AccessGuard< Type, Container, Traits > TThisType
TIterator End(void)
Get iterator pointing to the tail of the queue.
TIterator Begin(void)
Get iterator pointing to the head of the queue.
reverse_iterator< TIterator > TRevIterator
Type of reverse iterator returned from this guard.
TQueue::TIterator TIterator
Type of iterator returned from this guard.
CSyncQueue_AccessGuard(TQueue &queue_to_guard)
Constructor locking given queue.
TQueue & Queue(void) const
Get reference to queue which this object guards to use its constant access methods.
TIterator Erase(TIterator iter)
Erase one element in the queue.
TBaseType::TRevIterator TRevConstIterator
Type of reverse constant iterator returned from this guard.
CSyncQueue_AccessGuard(const TThisType &)
CSyncQueue_ConstAccessGuard< Type, Container, Traits > TBaseType
Short name of the ancestor class.
CSyncQueue< Type, Container, Traits > TQueue
Queue type that this object can guard.
TRevIterator REnd(void)
Get reverse iterator pointing to the head of the queue.
TQueue::TValue TValue
Type of values stored in the queue.
TQueue::TSize TSize
Type of size of the queue.
TQueue::TConstIterator TConstIterator
Type of constant iterator returned from this guard.
Access guard to a constant CSyncQueue.
CSyncQueue_ConstAccessGuard< Type, Container, Traits > TThisType
const CSyncQueue< Type, Container, Traits > TQueue
Queue type that this object can guard.
void x_RemoveIter(TIterBase *iter)
Remove iterator from the list of iterators owned by this object.
TQueue::TValue TValue
Type of values stored in the queue.
void x_AddIter(TIterBase *iter)
Add iterator to the list of iterators owned by this object.
TIterator Begin(void)
Get iterator pointing to the head of the queue.
TQueue & m_Queue
The queue object that this guard locks.
TQueue::TConstIterator TIterator
Type of iterator returned from this guard.
TThisType & operator=(const TThisType &)
TRevIterator TRevConstIterator
For convinience - type of reverse constant iterator.
~CSyncQueue_ConstAccessGuard()
Destructor â unlocks the guarded queue.
CSyncQueue_ConstAccessGuard(const TThisType &)
TQueue::TSize TSize
Type of size of the queue.
TRevIterator RBegin(void)
Get reverse iterator pointing to the tail of the queue.
CSyncQueue_I_Base< Type, Container > TIterBase
Base type for iterator and const_iterator for the queue.
reverse_iterator< TIterator > TRevIterator
Type of reverse iterator returned from this guard.
list< TIterBase * > m_Iters
List of iterators owned by this guard.
TIterator TConstIterator
For convinience - type of constant iterator.
TIterator End(void)
Get iterator pointing to the tail of the queue.
CSyncQueue_ConstAccessGuard(TQueue &queue_to_guard)
Constructor â locks a queue.
TQueue & Queue(void) const
Get reference to queue which this object guards to use its constant access methods.
TRevIterator REnd(void)
Get reverse iterator pointing to the head of the queue.
Default traits for the CSyncQueue class.
static bool IsUsedConcurrently(void)
Tells if the queue can be used from many threads.
static void CSyncQueue_Traits_Must_Be_Inherited_From_CSyncQueue_DefaultTraits(void)
At the moment the only requirement to the traits is to provide a static function which tells f the qu...
Base class for both iterator and const_iterator for SyncQueue Used internally for unifying storage of...
virtual ~CSyncQueue_I_Base(void)
Virtual destructor.
virtual void Invalidate(void)=0
Invalidate this iterator.
Iterator for CSyncQueue (constant or non-constant depending on template parameters).
TNativeIterator m_Iter
Underlying native iterator.
TThisType & operator=(const TThisType &other)
TNativeIterator::reference TRef
Type of reference to stored value.
void CheckMatched(const TThisType &other) const
Check if this iterator can be compared to or subtracted from another iterator.
TNativeIterator::difference_type TDiff
Type of the difference between to iterators.
GetTypeWhenNotEqual< typename TQueue::TNativeConstIter, TNativeIterator >::Result TIntrnNativeConstIter
TNativeIterator::value_type value_type
CSyncQueue_ConstAccessGuard< Type, Container, Traits > TConstAccessGuard
Type of constant access guardian.
bool operator>(const TThisType &other) const
GetTypeWhenNotEqual< TNonConstIter, TThisType >::Result TInternalNonConst
Type for internal use only: non-constant iterator type if this iterator is constant and nothing if th...
TNativeIterator::iterator_category iterator_category
TRef operator[](TDiff offset) const
CSyncQueue_I< Type, Container, TNativeIterator, Traits > TThisType
Short name for this type.
TThisType & operator--(void)
void CheckGuard(TConstAccessGuard *guard) const
Check that this iterator belongs to given access guardian.
TQueue::TIterator TNonConstIter
Version of this class for non-constant iterating.
CSyncQueue_AccessGuard< Type, Container, Traits > TAccessGuard
Type of access guardian.
TNativeIterator x_GetBase() const
Get underlying native iterator.
TThisType & operator++(void)
bool operator<(const TThisType &other) const
bool operator==(const TThisType &other) const
bool m_Valid
The iterator validity flag.
CSyncQueue_I(const TThisType &other)
TThisType operator+(TDiff offset) const
TThisType operator-(TDiff offset) const
void CheckValid(void) const
Check if the iterator is valid. Throw CSyncQueueException if it is not.
bool operator<=(const TThisType &other) const
void Invalidate(void)
Invalidate this iterator.
TNativeIterator::pointer TPtr
Type of pointer to stored value.
bool operator!=(const TThisType &other) const
bool operator>=(const TThisType &other) const
CSyncQueue< Type, Container, Traits > TQueue
Queue type that this object will iterate over.
TConstAccessGuard * m_Guard
Access guard which owns this iterator.
Auto-lock the queue and unlock it when object will be destroyed.
CSyncQueue_InternalAutoLock()
Default ctor.
CSyncQueue_InternalAutoLock< Type, Container, Traits > TMyType
const TQueue * m_Queue
The queue that this object locks.
void Unlock()
Unlock the queue.
CSyncQueue< Type, Container, Traits > TQueue
Short name for queue type that this object can lock.
bool Lock(const TQueue *pqueue, const CTimeSpan *timeout=NULL)
Lock a queue.
CSyncQueue_InternalAutoLock(const TQueue *pqueue, const CTimeSpan *timeout=NULL)
Constructor â lock the queue and waiting for its lock for a given timeout.
CSyncQueue_InternalAutoLock(const TMyType &)
~CSyncQueue_InternalAutoLock()
Destructor â unlock the queue.
Convenience trait implementation which tells that the queue cannot be used from many threads.
static bool IsUsedConcurrently(void)
Convenience trait implementation which tells that the queue can be used from many threads.
static bool IsUsedConcurrently(void)
Adaptor class to use STL multiset<> in CSyncQueue.
TBaseType::iterator erase(typename TBaseType::iterator left, typename TBaseType::iterator right)
void push_back(const typename TBaseType::value_type &elem)
TBaseType::iterator erase(typename TBaseType::iterator iter)
TBaseType::const_reference front() const
multiset< Key, Compare, Allocator > TBaseType
Adaptor class to use STL priority_queue<> in CSyncQueue.
Container::pointer pointer
Container::difference_type difference_type
void push_back(const typename TBaseType::value_type &elem)
CSyncQueue_priority_queue()
Container::iterator iterator
Container::const_pointer const_pointer
priority_queue< Type, Container, Compare > TBaseType
TBaseType::const_reference front() const
Container::const_iterator const_iterator
Adaptor class to use STL set<> in CSyncQueue.
void push_back(const typename TBaseType::value_type &elem)
TBaseType::const_reference front() const
set< Key, Compare, Allocator > TBaseType
Thread-safe queue object with a blocking mechanism.
CAtomicCounter_WithAutoInit m_CntWaitNotFull
Number of threads waiting for the queue to become non-full.
@ kThreadSystemID_None
Value of thread system id that cannot be equal to any thread's id.
CAtomicCounter_WithAutoInit m_CntWaitNotEmpty
Number of threads waiting for the queue to become non-empty.
TNativeIter x_Erase(TNativeIter from_iter, TNativeIter to_iter)
Erase several elements from the underlying container.
void x_LockAndWaitWhileFull(TAutoLock *lock, const CTimeSpan *full_tmo, const CTimeSpan *service_tmo) const
Lock the queue and wait until it has room for more elements.
bool x_Lock(const CTimeSpan *timeout=NULL) const
Lock access to the queue.
CSyncQueue_I< Type, Container, TNativeConstIter, Traits > TConstIterator
Constant iterator on this queue.
Container::value_type TValue
Type of values stored in the queue.
int m_LockCount
Number of lockings of this queue with access guardians in one thread.
TSize GetSize(void) const
Get count of elements already stored in the queue.
atomic< TSize > m_Size
Current number of elements in the queue.
void x_Unlock(void) const
Unlock access to queue.
void x_Push_NonBlocking(const TValue &elem)
Add new element to the end of queue â without locking and blocking.
CSemaphore m_TrigNotFull
Semaphore to signal that the queue has become not full.
CSyncQueue(const TThisType &)
void(* TErrorThrower)(void)
Function to throw an exception; usually points to ThrowSyncQueueNoRoom() or ThrowSyncQueueEmpty()
TValue Pop(const CTimeSpan *full_tmo, const CTimeSpan *service_tmo)
Retrieve an element from the queue.
Container::size_type TSize
Type of size of the queue.
void x_GuardedUnlock(void) const
Unlock the queue by an access guard.
CSemaphore m_TrigNotEmpty
Semaphore to signal that the queue has become not empty.
void x_LockAndWaitWhileEmpty(TAutoLock *lock, const CTimeSpan *full_tmo, const CTimeSpan *service_tmo) const
Lock the queue and wait until it has at least one element.
TThisType & operator=(const TThisType &)
bool IsFull(void) const
Check if the queue is full (has maxSize elements)
void Push(const TValue &elem, const CTimeSpan *timeout=NULL)
Add new element to the end of queue.
Container m_Store
Underlying container to store queue elements.
void x_Clear_NonBlocking(void)
Clear the queue â without locking and blocking.
CSyncQueue_AccessGuard< Type, Container, Traits > TAccessGuard
Type of access guardian for non-constant queue.
TNativeIter x_End(void)
Get iterator pointing to the end of underlying container.
void Push(const TValue &elem, const CTimeSpan *full_tmo, const CTimeSpan *service_tmo)
Add new element to the end of queue.
Container::iterator TNativeIter
Type of underlying iterator.
const TSize m_MaxSize
Maximum size of the queue.
CSemaphore m_TrigLock
Semaphore to signal that the queue can be safely modified.
TValue x_Pop_NonBlocking(void)
Get first element from the queue â without locking and blocking.
void x_DoubleLock(TAutoLock *my_lock, TAutoLock *other_lock, const TThisType &other_obj) const
Lock two queues simultaneously to guard against otherwise possible inter-thread dead-lock.
bool x_IsGuarded(void) const
Check if this queue is locked by some access guard in current thread.
void x_LockAndWait(TAutoLock *lock, const CTimeSpan *full_tmo, const CTimeSpan *service_tmo, TCheckFunc func_to_check, CSemaphore *trigger, CAtomicCounter *counter, TErrorThrower throw_error) const
Lock the queue and wait until the condition function returns FALSE.
void CopyTo(TThisType *other) const
Copy (add) all queue elements to another queue.
bool IsEmpty(void) const
Check if the queue is empty.
TNativeConstIter x_Begin(void) const
Get constant iterator pointing to the start of underlying container.
TValue Pop(const CTimeSpan *timeout=NULL)
Retrieve an element from the queue.
TSize GetMaxSize(void) const
Get the maximum # of elements allowed to be kept in the queue.
CSyncQueue_ConstAccessGuard< Type, Container, Traits > TConstAccessGuard
Type of access guardian for constant queue.
CSyncQueue_InternalAutoLock< Type, Container, Traits > TAutoLock
Short name of auto-lock for this queue type.
TNativeConstIter x_End(void) const
Get constant iterator pointing to the end of underlying container.
atomic< TThreadSystemID > m_CurGuardTID
ID of the thread in which the queue has been locked by a guardian.
CSyncQueue_I< Type, Container, TNativeIter, Traits > TIterator
Non-constant iterator on this queue.
TNativeIter x_Begin(void)
Get iterator pointing to the start of underlying container.
void Clear(const CTimeSpan *timeout=NULL)
Remove all elements from the queue.
Container::const_iterator TNativeConstIter
Type of underlying constant iterator.
CSyncQueue(TSize max_size=numeric_limits< TSize >::max())
Construct queue.
TNativeIter x_Erase(TNativeIter iter)
Erase one element from the underlying container.
bool(CSyncQueue::* TCheckFunc)(void) const
Function to check condition; usually points to IsFull() or IsEmpty()
void x_GuardedLock(const CTimeSpan *timeout=NULL) const
Lock the queue by an access guard.
CSyncQueue< Type, Container, Traits > TThisType
Short name of this queue type.
CTimeout â Timeout interval.
parent_type::value_type value_type
parent_type::iterator iterator
Concept for allocating, resizing and freeing memory block.
parent_type::value_type value_type
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
@ ePositive
Value is positive.
TValue Add(int delta) THROWS_NONE
Atomically add value (=delta), and return new counter value.
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
EErrCode
Error types that an application can generate.
CVect2< NCBI_PROMOTE(int,U) > operator*(int v1, const CVect2< U > &v2)
CBeginInfo Begin(C &obj)
Get starting point of object hierarchy.
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
void Wait(void)
Wait on semaphore.
static unsigned int GetThreadsCount()
Get total amount of threads This amount does not contain main thread.
pthread_t TThreadSystemID
Define platform-dependent thread ID type.
bool TryWait(unsigned int timeout_sec=0, unsigned int timeout_nsec=0)
Timed wait.
static TThreadSystemID GetCurrentThreadSystemID(void)
Get the current thread ID.
double Elapsed(void) const
Return time elapsed since first Start() or last Restart() call (in seconds).
ESign GetSign(void) const
Get sign of time span.
@ eStart
Start timer immediately after creating.
#define NCBI_XNCBI_EXPORT
CNcbiMatrix< T > & operator+=(CNcbiMatrix< T > &, const CNcbiMatrix< U > &)
global addition: matrix += matrix
CNcbiMatrix< T > & operator-=(CNcbiMatrix< T > &, const CNcbiMatrix< U > &)
global subtraction: matrix -= matrix
vector< CSeq_align const * >::const_iterator TIterator
constexpr bool empty(list< Ts... >) noexcept
double value_type
The numeric datatype used by the parser.
const GenericPointer< typename T::ValueType > & pointer
static string x_Lock(EMT_Lock how)
NCBI C++ auxiliary debug macros.
Defines NCBI C++ exception handling.
Multi-threading â mutexes; rw-locks; semaphore.
Multi-threading â classes, functions, and features.
Defines: CTimeFormat - storage class for time format.
S & operator--(CNetRef< S > &r, int)
Int4 delta(size_t dimension_, const Int4 *score_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
int Queue(const string &service, shared_ptr< CPSG_Request > request, CTimeout timeout)
GetTypeWhenNotEqual< Type, Type > Result
Helper template returning some Type when it's not equal to NotType.
CSyncQueue_I< Type, Container, TNativeIterator, Traits > operator+(typename CSyncQueue_I< Type, Container, TNativeIterator, Traits >::TDiff offset, const CSyncQueue_I< Type, Container, TNativeIterator, Traits > &iter)
bool operator!=(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
bool operator<=(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
CSyncQueue_I< Type, Container, TNativeIterL, Traits >::TDiff operator-(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
bool operator<(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
bool operator>=(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
bool operator>(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
void ThrowSyncQueueEmpty(void)
Throw an exception about empty queue with standard message.
void ThrowSyncQueueNoRoom(void)
Throw an exception about no room in a queue with standard message.
bool operator==(const CSyncQueue_I< Type, Container, TNativeIterL, Traits > &left, const CSyncQueue_I< Type, Container, TNativeIterR, Traits > &right)
void ThrowSyncQueueTimeout(void)
Throw an exception about expired timeout with standard message.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4