CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Private Attributes
edm::ThreadSafeAddOnlyContainer< T > Class Template Reference

#include <ThreadSafeAddOnlyContainer.h>

Classes

class  Node
 

Public Member Functions

template<typename... Args>
TmakeAndHold (Args &&...args)
 
 ThreadSafeAddOnlyContainer ()
 
 ~ThreadSafeAddOnlyContainer ()
 

Private Attributes

std::atomic< Node * > front_
 

Detailed Description

template<typename T>
class edm::ThreadSafeAddOnlyContainer< T >

Definition at line 31 of file ThreadSafeAddOnlyContainer.h.

Constructor & Destructor Documentation

Definition at line 62 of file ThreadSafeAddOnlyContainer.h.

62  :
63  front_(nullptr) {
64  }

Definition at line 67 of file ThreadSafeAddOnlyContainer.h.

References edm::ThreadSafeAddOnlyContainer< T >::front_, GetRecoTauVFromDQM_MC_cff::next, and edm::ThreadSafeAddOnlyContainer< T >::Node::next().

67  {
68  Node const* node = front_.load();
69  while (node) {
70  Node const* next = node->next();
71  delete node;
72  node = next;
73  }
74  }

Member Function Documentation

template<typename T >
template<typename... Args>
T * edm::ThreadSafeAddOnlyContainer< T >::makeAndHold ( Args &&...  args)

Definition at line 78 of file ThreadSafeAddOnlyContainer.h.

References edm::ThreadSafeAddOnlyContainer< T >::Node::address(), createfilelist::args, edm::ThreadSafeAddOnlyContainer< T >::front_, and edm::ThreadSafeAddOnlyContainer< T >::Node::setNext().

78  {
79  Node* expected = front_.load();
80  Node* newNode = new Node(expected, std::forward<Args>(args)...);
81  while (!front_.compare_exchange_strong(expected, newNode)) {
82  // another thread changed front_ before us so try again
83  newNode->setNext(expected);
84  }
85  return newNode->address();
86  }

Member Data Documentation

template<typename T >
std::atomic<Node*> edm::ThreadSafeAddOnlyContainer< T >::front_
private