Main Page
Namespaces
Classes
Package Documentation
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
FWCore
Concurrency
interface
TaskBase.h
Go to the documentation of this file.
1
#ifndef FWCore_Concurrency_TaskBase_h
2
#define FWCore_Concurrency_TaskBase_h
3
// -*- C++ -*-
4
//
5
// Package: Concurrency
6
// Class : TaskBase
7
//
15
//
16
// Original Author: Chris Jones
17
// Created: Tue Jan 5 13:46:31 CST 2020
18
// $Id$
19
//
20
21
// system include files
22
#include <atomic>
23
#include <exception>
24
#include <memory>
25
26
// user include files
27
28
// forward declarations
29
30
namespace
edm {
31
class
TaskBase
{
32
public
:
33
friend
class
TaskSentry
;
34
36
TaskBase
() :
m_refCount
{0} {}
37
virtual
~TaskBase
() =
default
;
38
39
virtual
void
execute
() = 0;
40
41
void
increment_ref_count
() { ++
m_refCount
; }
42
unsigned
int
decrement_ref_count
() {
return
--
m_refCount
; }
43
44
private
:
45
virtual
void
recycle
() {
delete
this
; }
46
47
std::atomic<unsigned int>
m_refCount
{0};
48
};
49
50
class
TaskSentry
{
51
public
:
52
TaskSentry
(
TaskBase
* iTask) :
m_task
{iTask} {}
53
~TaskSentry
() {
m_task
->
recycle
(); }
54
TaskSentry
() =
delete
;
55
TaskSentry
(
TaskSentry
const
&) =
delete
;
56
TaskSentry
(
TaskSentry
&&) =
delete
;
57
TaskSentry
operator=
(
TaskSentry
const
&) =
delete
;
58
TaskSentry
operator=
(
TaskSentry
&&) =
delete
;
59
60
private
:
61
TaskBase
*
m_task
;
62
};
63
}
// namespace edm
64
65
#endif
edm::TaskBase
Definition:
TaskBase.h:31
edm::TaskBase::execute
virtual void execute()=0
edm::TaskSentry::~TaskSentry
~TaskSentry()
Definition:
TaskBase.h:53
edm::TaskSentry::m_task
TaskBase * m_task
Definition:
TaskBase.h:61
edm::TaskSentry::TaskSentry
TaskSentry(TaskBase *iTask)
Definition:
TaskBase.h:52
edm::TaskBase::recycle
virtual void recycle()
Definition:
TaskBase.h:45
edm::TaskSentry::TaskSentry
TaskSentry()=delete
edm::TaskBase::~TaskBase
virtual ~TaskBase()=default
edm::TaskBase::m_refCount
std::atomic< unsigned int > m_refCount
Definition:
TaskBase.h:47
edm::TaskBase::TaskBase
TaskBase()
Constructor.
Definition:
TaskBase.h:36
edm::TaskBase::decrement_ref_count
unsigned int decrement_ref_count()
Definition:
TaskBase.h:42
edm::TaskSentry::operator=
TaskSentry operator=(TaskSentry const &)=delete
edm::TaskBase::increment_ref_count
void increment_ref_count()
Definition:
TaskBase.h:41
edm::TaskSentry
Definition:
TaskBase.h:50
Generated for CMSSW Reference Manual by
1.8.5