Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1036 from Dr15Jones/serializeEventSetupModules
Multithreaded framework -- Serialize calls to EventSetup modules
- Loading branch information
Showing
37 changed files
with
710 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
#ifndef Subsystem_Package_SharedResourcesAcquirer_h | ||
#define Subsystem_Package_SharedResourcesAcquirer_h | ||
// -*- C++ -*- | ||
// | ||
// Package: Subsystem/Package | ||
// Class : SharedResourcesAcquirer | ||
// | ||
/**\class SharedResourcesAcquirer SharedResourcesAcquirer.h "SharedResourcesAcquirer.h" | ||
Description: Handles acquiring and releasing a group of resources shared between modules | ||
Usage: | ||
<usage> | ||
*/ | ||
// | ||
// Original Author: Chris Jones | ||
// Created: Sun, 06 Oct 2013 19:43:26 GMT | ||
// | ||
|
||
// system include files | ||
|
||
// user include files | ||
#include <vector> | ||
#include <mutex> | ||
#include <memory> | ||
|
||
// forward declarations | ||
class testSharedResourcesRegistry; | ||
namespace edm { | ||
class SharedResourcesAcquirer | ||
{ | ||
public: | ||
friend class ::testSharedResourcesRegistry; | ||
|
||
SharedResourcesAcquirer() = default; | ||
explicit SharedResourcesAcquirer(std::vector<std::recursive_mutex*>&& iResources): | ||
m_resources(iResources){} | ||
|
||
SharedResourcesAcquirer(SharedResourcesAcquirer&&) = default; | ||
SharedResourcesAcquirer(const SharedResourcesAcquirer&) = default; | ||
SharedResourcesAcquirer& operator=(const SharedResourcesAcquirer&) = default; | ||
|
||
~SharedResourcesAcquirer() = default; | ||
|
||
// ---------- member functions --------------------------- | ||
void lock(); | ||
void unlock(); | ||
|
||
///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 | ||
template<typename FUNC> | ||
void temporaryUnlock(FUNC iFunc) { | ||
std::shared_ptr<SharedResourcesAcquirer*> guard(this,[](SharedResourcesAcquirer* iThis) {iThis->lock();}); | ||
this->unlock(); | ||
iFunc(); | ||
} | ||
|
||
///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. | ||
size_t numberOfResources() const { return m_resources.size();} | ||
private: | ||
|
||
// ---------- member data -------------------------------- | ||
std::vector<std::recursive_mutex*> m_resources; | ||
}; | ||
} | ||
|
||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.