12#ifdef epicsExportSharedSymbols
13# define fairQueueExportSharedSymbols
14# undef epicsExportSharedSymbols
17#include <epicsEvent.h>
18#include <epicsMutex.h>
19#include <epicsGuard.h>
23#include <pv/sharedPtr.h>
25#ifdef fairQueueExportSharedSymbols
26# define epicsExportSharedSymbols
27# undef fairQueueExportSharedSymbols
61 typedef epicsGuard<epicsMutex> guard_t;
63 typedef std::tr1::shared_ptr<T> value_type;
79 friend class fair_queue;
84 entry() :Qcnt(0), holder()
87 enode.node.next = enode.node.previous = NULL;
92 assert(!enode.node.next && !enode.node.previous);
93 assert(Qcnt==0 && !holder);
105 assert(ellCount(&list)==0);
117 garbage.
resize(
unsigned(ellCount(&list)));
120 while(ELLNODE *cur = ellGet(&list)) {
121 typedef typename entry::enode_t enode_t;
122 enode_t *PN = CONTAINER(cur, enode_t, node);
124 assert(P->owner==
this);
127 PN->node.previous = PN->node.next = NULL;
130 garbage[i++].
swap(P->holder);
137 return ellFirst(&list)==NULL;
140 void push_back(
const value_type& ent)
143 entry *P = ent.get();
146 wake = ellFirst(&list)==NULL;
150 assert(P->owner==NULL);
153 ellAdd(&list, &P->enode.node);
155 assert(P->owner==
this);
157 if(wake) wakeup.signal();
160 bool pop_front_try(value_type& ret)
164 ELLNODE *cur = ellGet(&list);
167 typedef typename entry::enode_t enode_t;
168 enode_t *PN = CONTAINER(cur, enode_t, node);
170 assert(P->owner==
this);
173 PN->node.previous = PN->node.next = NULL;
178 ellAdd(&list, &P->enode.node);
188 void pop_front(value_type& ret)
198 bool pop_front(value_type& ret,
double timeout)
204 if(!wakeup.wait(timeout))
211 mutable epicsMutex mutex;
212 mutable epicsEvent wakeup;
constexpr complex< _Tp > & operator=(const _Tp &)
constexpr void swap(vector &__x) noexcept
constexpr void resize(size_type __new_size)
Copyright - See the COPYRIGHT that is included with this distribution.