forked from cms-patatrack/pixeltrack-standalone
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Following cms-sw/cmssw#32804
- Loading branch information
Showing
13 changed files
with
288 additions
and
152 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,65 @@ | ||
#ifndef FWCore_Concurrency_TaskBase_h | ||
#define FWCore_Concurrency_TaskBase_h | ||
// -*- C++ -*- | ||
// | ||
// Package: Concurrency | ||
// Class : TaskBase | ||
// | ||
/**\class TaskBase TaskBase.h FWCore/Concurrency/interface/TaskBase.h | ||
Description: Base class for tasks. | ||
Usage: | ||
Used as a callback to happen after a task has been completed. | ||
*/ | ||
// | ||
// Original Author: Chris Jones | ||
// Created: Tue Jan 5 13:46:31 CST 2020 | ||
// $Id$ | ||
// | ||
|
||
// system include files | ||
#include <atomic> | ||
#include <exception> | ||
#include <memory> | ||
|
||
// user include files | ||
|
||
// forward declarations | ||
|
||
namespace edm { | ||
class TaskBase { | ||
public: | ||
friend class TaskSentry; | ||
|
||
///Constructor | ||
TaskBase() : m_refCount{0} {} | ||
virtual ~TaskBase() = default; | ||
|
||
virtual void execute() = 0; | ||
|
||
void increment_ref_count() { ++m_refCount; } | ||
unsigned int decrement_ref_count() { return --m_refCount; } | ||
|
||
private: | ||
virtual void recycle() { delete this; } | ||
|
||
std::atomic<unsigned int> m_refCount{0}; | ||
}; | ||
|
||
class TaskSentry { | ||
public: | ||
TaskSentry(TaskBase* iTask) : m_task{iTask} {} | ||
~TaskSentry() { m_task->recycle(); } | ||
TaskSentry() = delete; | ||
TaskSentry(TaskSentry const&) = delete; | ||
TaskSentry(TaskSentry&&) = delete; | ||
TaskSentry operator=(TaskSentry const&) = delete; | ||
TaskSentry operator=(TaskSentry&&) = delete; | ||
|
||
private: | ||
TaskBase* m_task; | ||
}; | ||
} // namespace edm | ||
|
||
#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
Oops, something went wrong.