-
Notifications
You must be signed in to change notification settings - Fork 0
/
RunCache.h
61 lines (49 loc) · 1.28 KB
/
RunCache.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#ifndef Subsystem_Package_RunCache_h
#define Subsystem_Package_RunCache_h
// -*- C++ -*-
//
// Package: Package
// Class : RunCache
//
/**\class RunCache RunCache.h "RunCache.h"
Description: [one line class summary]
Usage:
<usage>
*/
//
// Original Author: Chris Jones
// Created: Thu, 14 Mar 2013 19:13:54 GMT
// $Id$
//
// system include files
#include <atomic>
#include <vector>
#include <memory>
#include <functional>
// user include files
#include "Run.h"
#include "SerialTaskQueue.h"
#include "WaitingTaskList.h"
// forward declarations
class Coordinator;
class Stream;
class Source;
class GlobalWatcher;
class RunCache{
public:
explicit RunCache(unsigned int iNRuns);
unsigned int maxNumberOfConcurrentRuns() const {return m_runs.size();}
///Returns nullptr if no available run slot
/// This must be called serially
Run* getARun();
void waitForAnAvailableRun(tbb::task*);
//this can be called asynchronously
void doneWithRun(unsigned int iCacheID);
private:
std::vector<Run> m_runs;
std::vector<std::atomic<bool>> m_runAvailable;
std::atomic<unsigned int> m_nAvailableRuns;
std::atomic<bool> m_waitingForAvailableRun;
edm::WaitingTaskList m_tasksWaitingForAvailableRun;
};
#endif