CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes | Friends
edm::SharedResourcesAcquirer Class Reference

#include <SharedResourcesAcquirer.h>

Public Member Functions

void lock ()
 
size_t numberOfResources () const
 The number returned may be less than the number of resources requested if a resource is only used by one module and therefore is not being shared. More...
 
SharedResourcesAcquireroperator= (const SharedResourcesAcquirer &)=default
 
 SharedResourcesAcquirer ()=default
 
 SharedResourcesAcquirer (std::vector< std::recursive_mutex * > &&iResources)
 
 SharedResourcesAcquirer (SharedResourcesAcquirer &&)=default
 
 SharedResourcesAcquirer (const SharedResourcesAcquirer &)=default
 
template<typename FUNC >
void temporaryUnlock (FUNC iFunc)
 
void unlock ()
 
 ~SharedResourcesAcquirer ()=default
 

Private Attributes

std::vector
< std::recursive_mutex * > 
m_resources
 

Friends

class ::testSharedResourcesRegistry
 

Detailed Description

Definition at line 31 of file SharedResourcesAcquirer.h.

Constructor & Destructor Documentation

edm::SharedResourcesAcquirer::SharedResourcesAcquirer ( )
default
edm::SharedResourcesAcquirer::SharedResourcesAcquirer ( std::vector< std::recursive_mutex * > &&  iResources)
inlineexplicit

Definition at line 37 of file SharedResourcesAcquirer.h.

37  :
38  m_resources(iResources){}
std::vector< std::recursive_mutex * > m_resources
edm::SharedResourcesAcquirer::SharedResourcesAcquirer ( SharedResourcesAcquirer &&  )
default
edm::SharedResourcesAcquirer::SharedResourcesAcquirer ( const SharedResourcesAcquirer )
default
edm::SharedResourcesAcquirer::~SharedResourcesAcquirer ( )
default

Member Function Documentation

void SharedResourcesAcquirer::lock ( void  )

Definition at line 20 of file SharedResourcesAcquirer.cc.

References m, and m_resources.

Referenced by temporaryUnlock().

20  {
21  for(auto m : m_resources) {
22  m->lock();
23  }
24  }
std::vector< std::recursive_mutex * > m_resources
size_t edm::SharedResourcesAcquirer::numberOfResources ( ) const
inline

The number returned may be less than the number of resources requested if a resource is only used by one module and therefore is not being shared.

Definition at line 60 of file SharedResourcesAcquirer.h.

References m_resources.

60 { return m_resources.size();}
std::vector< std::recursive_mutex * > m_resources
SharedResourcesAcquirer& edm::SharedResourcesAcquirer::operator= ( const SharedResourcesAcquirer )
default
template<typename FUNC >
void edm::SharedResourcesAcquirer::temporaryUnlock ( FUNC  iFunc)
inline

Used by the framework to temporarily unlock a resource in the case where a module is temporarily suspended, e.g. when a Event::getByLabel call launches a Producer via unscheduled processing

Definition at line 53 of file SharedResourcesAcquirer.h.

References lock(), and unlock().

53  {
54  std::shared_ptr<SharedResourcesAcquirer*> guard(this,[](SharedResourcesAcquirer* iThis) {iThis->lock();});
55  this->unlock();
56  iFunc();
57  }
void SharedResourcesAcquirer::unlock ( void  )

Definition at line 26 of file SharedResourcesAcquirer.cc.

References m_resources.

Referenced by temporaryUnlock().

26  {
27  for(auto it = m_resources.rbegin(), itEnd = m_resources.rend();
28  it != itEnd; ++it) {
29  (*it)->unlock();
30  }
31  }
std::vector< std::recursive_mutex * > m_resources

Friends And Related Function Documentation

friend class ::testSharedResourcesRegistry
friend

Definition at line 34 of file SharedResourcesAcquirer.h.

Member Data Documentation

std::vector<std::recursive_mutex*> edm::SharedResourcesAcquirer::m_resources
private

Definition at line 64 of file SharedResourcesAcquirer.h.

Referenced by lock(), numberOfResources(), and unlock().