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 175 of file ConcurrentQueue.h.

Member Typedef Documentation

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

Definition at line 180 of file ConcurrentQueue.h.

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

Definition at line 178 of file ConcurrentQueue.h.

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

Definition at line 179 of file ConcurrentQueue.h.

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

Definition at line 177 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 199 of file ConcurrentQueue.h.

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

209  {
210  SizeType elementsRemoved(0);
211  detail::MemoryType itemSize = detail::memoryUsage(item);
212  while ( (size==capacity || used+itemSize > memory) && !elements.empty() )
213  {
214  SequenceType holder;
215  // Move the item out of elements in a manner that will not throw.
216  holder.splice(holder.begin(), elements, elements.begin());
217  // Record the change in the length of elements.
218  --size;
219  used -= detail::memoryUsage( holder.front() );
220  ++elementsRemoved;
221  }
222  if (size < capacity && used+itemSize <= memory)
223  // we succeeded to make enough room for the new element
224  {
225  doInsert(item, elements, size, itemSize, used, nonempty);
226  }
227  else
228  {
229  // we cannot add the new element
230  ++elementsRemoved;
231  }
232  elementsDropped += elementsRemoved;
233  return elementsRemoved;
234  }
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 183 of file ConcurrentQueue.h.

References findQualityFiles::size.

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

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