CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DiskWriterResources.cc
Go to the documentation of this file.
1 // $Id: DiskWriterResources.cc,v 1.8 2011/03/07 15:31:32 mommsen Exp $
3 
5 
6 namespace stor
7 {
9  configurationIsNeeded_(false),
10  streamChangeIsNeeded_(false),
11  fileClosingTestIsNeeded_(false),
12  diskWriterIsBusy_(false),
13  streamChangeInProgress_(false)
14  {
15  }
16 
18  (
19  EvtStrConfigListPtr const evtStrConfig,
20  ErrStrConfigListPtr const errStrConfig,
21  DiskWritingParams const& dwParams,
22  unsigned int const& runNumber,
23  boost::posix_time::time_duration const& timeoutValue
24  )
25  {
26  boost::mutex::scoped_lock sl(streamChangeMutex_);
27 
28  requestedEventStreamConfig_ = evtStrConfig;
29  requestedErrorStreamConfig_ = errStrConfig;
30  requestedDiskWritingParams_ = dwParams;
31  requestedRunNumber_ = runNumber;
32  requestedTimeout_ = timeoutValue;
33  configurationIsNeeded_ = true;
34  streamChangeIsNeeded_ = true;
35  }
36 
38  {
39  boost::mutex::scoped_lock sl(streamChangeMutex_);
40  configurationIsNeeded_ = false;
41  streamChangeIsNeeded_ = true;
42  }
43 
45  (
46  bool& doConfig,
47  EvtStrConfigListPtr& evtStrConfig,
48  ErrStrConfigListPtr& errStrConfig,
49  DiskWritingParams& dwParams,
50  unsigned int& runNumber,
51  boost::posix_time::time_duration& timeoutValue
52  )
53  {
54  boost::mutex::scoped_lock sl(streamChangeMutex_);
55 
56  if (! streamChangeIsNeeded_) {return false;}
57 
58  streamChangeIsNeeded_ = false;
59 
60  doConfig = configurationIsNeeded_;
61  if (configurationIsNeeded_)
62  {
63  configurationIsNeeded_ = false;
64  evtStrConfig = requestedEventStreamConfig_;
65  errStrConfig = requestedErrorStreamConfig_;
66  dwParams = requestedDiskWritingParams_;
67  runNumber = requestedRunNumber_;
68  timeoutValue = requestedTimeout_;
69  }
70 
71  streamChangeInProgress_ = true;
72 
73  return true;
74  }
75 
77  {
78  boost::mutex::scoped_lock sl(streamChangeMutex_);
80  {
81  streamChangeCondition_.wait(sl);
82  }
83  }
84 
86  {
87  boost::mutex::scoped_lock sl(streamChangeMutex_);
89  }
90 
92  {
93  boost::mutex::scoped_lock sl(streamChangeMutex_);
95  {
96  streamChangeCondition_.notify_one();
97  }
99  }
100 
101  void DiskWriterResources::setBusy(bool isBusyFlag)
102  {
103  //boost::mutex::scoped_lock sl(generalMutex_);
104  diskWriterIsBusy_ = isBusyFlag;
105  }
106 
108  {
109  //boost::mutex::scoped_lock sl(generalMutex_);
110  return diskWriterIsBusy_;
111  }
112 
113 } // namespace stor
114 
boost::shared_ptr< ErrStrConfigList > ErrStrConfigListPtr
boost::condition streamChangeCondition_
boost::shared_ptr< EvtStrConfigList > EvtStrConfigListPtr
void setBusy(bool isBusyFlag)
void requestStreamConfiguration(EvtStrConfigListPtr const, ErrStrConfigListPtr const, DiskWritingParams const &, unsigned int const &runNumber, boost::posix_time::time_duration const &timeoutValue)
bool streamChangeRequested(bool &doConfig, EvtStrConfigListPtr &, ErrStrConfigListPtr &, DiskWritingParams &dwParams, unsigned int &runNumber, boost::posix_time::time_duration &timeoutValue)