File indexing completed on 2024-04-06 12:12:38
0001 #ifndef FWCore_Integration_WaitingService_h
0002 #define FWCore_Integration_WaitingService_h
0003
0004 #include "WaitingServer.h"
0005
0006 #include <atomic>
0007 #include <memory>
0008 #include <vector>
0009
0010 namespace edm {
0011 class ActivityRegistry;
0012 class ParameterSet;
0013 namespace service {
0014 class SystemBounds;
0015 }
0016 }
0017
0018 namespace edmtest {
0019 namespace test_acquire {
0020
0021 class Token {
0022 public:
0023 Token(unsigned int v) : value_(v) {}
0024 unsigned int value() const { return value_; }
0025
0026 private:
0027 unsigned int value_;
0028 };
0029
0030 class WaitingService {
0031 public:
0032 WaitingService(edm::ParameterSet const& pset, edm::ActivityRegistry& iRegistry);
0033 ~WaitingService();
0034
0035 Token getToken() { return Token(count_.fetch_add(1)); }
0036
0037 void preallocate(edm::service::SystemBounds const&);
0038
0039 Cache* getCache(Token const& token) { return &caches_[token.value()]; }
0040
0041 void requestValuesAsync(Token const& token,
0042 std::vector<int> const* iIn,
0043 std::vector<int>* iOut,
0044 edm::WaitingTaskWithArenaHolder& holder) {
0045 server_->requestValuesAsync(token.value(), iIn, iOut, holder);
0046 }
0047
0048 void postEndJob();
0049
0050 private:
0051 std::atomic<unsigned int> count_;
0052 std::vector<Cache> caches_;
0053 std::unique_ptr<WaitingServer> server_;
0054 const unsigned int numberOfStreamsToAccumulate_;
0055 const unsigned int secondsToWaitForWork_;
0056 };
0057 }
0058 }
0059 #endif