CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Static Public Member Functions
stor::KeepNewest< T > Struct Template Reference

#include <ConcurrentQueue.h>

Public Types

typedef SizeType ReturnType
 
typedef std::list< TSequenceType
 
typedef SequenceType::size_type SizeType
 
typedef std::pair< T, size_t > ValueType
 

Static Public Member Functions

static ReturnType doEnq (T const &item, SequenceType &elements, SizeType &size, SizeType &capacity, detail::MemoryType &used, detail::MemoryType &memory, size_t &elementsDropped, boost::condition &nonempty)
 
static void doInsert (T const &item, SequenceType &elements, SizeType &size, detail::MemoryType const &itemSize, detail::MemoryType &used, boost::condition &nonempty)
 

Detailed Description

template<class T>
struct stor::KeepNewest< T >

Definition at line 173 of file ConcurrentQueue.h.

Member Typedef Documentation

template<class T >
typedef SizeType stor::KeepNewest< T >::ReturnType

Definition at line 178 of file ConcurrentQueue.h.

template<class T >
typedef std::list<T> stor::KeepNewest< T >::SequenceType

Definition at line 176 of file ConcurrentQueue.h.

template<class T >
typedef SequenceType::size_type stor::KeepNewest< T >::SizeType

Definition at line 177 of file ConcurrentQueue.h.

template<class T >
typedef std::pair<T,size_t> stor::KeepNewest< T >::ValueType

Definition at line 175 of file ConcurrentQueue.h.

Member Function Documentation

template<class T >
static ReturnType stor::KeepNewest< T >::doEnq ( T const &  item,
SequenceType elements,
SizeType size,
SizeType capacity,
detail::MemoryType used,
detail::MemoryType memory,
size_t &  elementsDropped,
boost::condition &  nonempty 
)
inlinestatic

Definition at line 197 of file ConcurrentQueue.h.

References stor::KeepNewest< T >::doInsert(), asciidump::elements, stor::detail::memoryUsage(), and findQualityFiles::size.

207  {
208  SizeType elementsRemoved(0);
209  detail::MemoryType itemSize = detail::memoryUsage(item);
210  while ( (size==capacity || used+itemSize > memory) && !elements.empty() )
211  {
212  SequenceType holder;
213  // Move the item out of elements in a manner that will not throw.
214  holder.splice(holder.begin(), elements, elements.begin());
215  // Record the change in the length of elements.
216  --size;
217  used -= detail::memoryUsage( holder.front() );
218  ++elementsRemoved;
219  }
220  if (size < capacity && used+itemSize <= memory)
221  // we succeeded to make enough room for the new element
222  {
223  doInsert(item, elements, size, itemSize, used, nonempty);
224  }
225  else
226  {
227  // we cannot add the new element
228  ++elementsRemoved;
229  }
230  elementsDropped += elementsRemoved;
231  return elementsRemoved;
232  }
Definition: vlib.h:187
static void doInsert(T const &item, SequenceType &elements, SizeType &size, detail::MemoryType const &itemSize, detail::MemoryType &used, boost::condition &nonempty)
list elements
Definition: asciidump.py:414
SequenceType::size_type SizeType
std::list< T > SequenceType
MemoryType memoryUsage(const std::pair< T, size_t > &t)
tuple size
Write out results.
template<class T >
static void stor::KeepNewest< T >::doInsert ( T const &  item,
SequenceType elements,
SizeType size,
detail::MemoryType const &  itemSize,
detail::MemoryType used,
boost::condition &  nonempty 
)
inlinestatic

Definition at line 181 of file ConcurrentQueue.h.

References findQualityFiles::size.

Referenced by stor::KeepNewest< T >::doEnq().

189  {
190  elements.push_back(item);
191  ++size;
192  used += itemSize;
193  nonempty.notify_one();
194  }
list elements
Definition: asciidump.py:414
tuple size
Write out results.