Go to the documentation of this file.00001
00003
00004 #include "EventFilter/StorageManager/interface/DiskWriterResources.h"
00005
00006 namespace stor
00007 {
00008 DiskWriterResources::DiskWriterResources() :
00009 configurationIsNeeded_(false),
00010 streamChangeIsNeeded_(false),
00011 fileClosingTestIsNeeded_(false),
00012 diskWriterIsBusy_(false),
00013 streamChangeInProgress_(false)
00014 {
00015 }
00016
00017 void DiskWriterResources::requestStreamConfiguration
00018 (
00019 EvtStrConfigListPtr const evtStrConfig,
00020 ErrStrConfigListPtr const errStrConfig,
00021 DiskWritingParams const& dwParams,
00022 unsigned int const& runNumber,
00023 boost::posix_time::time_duration const& timeoutValue
00024 )
00025 {
00026 boost::mutex::scoped_lock sl(streamChangeMutex_);
00027
00028 requestedEventStreamConfig_ = evtStrConfig;
00029 requestedErrorStreamConfig_ = errStrConfig;
00030 requestedDiskWritingParams_ = dwParams;
00031 requestedRunNumber_ = runNumber;
00032 requestedTimeout_ = timeoutValue;
00033 configurationIsNeeded_ = true;
00034 streamChangeIsNeeded_ = true;
00035 }
00036
00037 void DiskWriterResources::requestStreamDestruction()
00038 {
00039 boost::mutex::scoped_lock sl(streamChangeMutex_);
00040 configurationIsNeeded_ = false;
00041 streamChangeIsNeeded_ = true;
00042 }
00043
00044 bool DiskWriterResources::streamChangeRequested
00045 (
00046 bool& doConfig,
00047 EvtStrConfigListPtr& evtStrConfig,
00048 ErrStrConfigListPtr& errStrConfig,
00049 DiskWritingParams& dwParams,
00050 unsigned int& runNumber,
00051 boost::posix_time::time_duration& timeoutValue
00052 )
00053 {
00054 boost::mutex::scoped_lock sl(streamChangeMutex_);
00055
00056 if (! streamChangeIsNeeded_) {return false;}
00057
00058 streamChangeIsNeeded_ = false;
00059
00060 doConfig = configurationIsNeeded_;
00061 if (configurationIsNeeded_)
00062 {
00063 configurationIsNeeded_ = false;
00064 evtStrConfig = requestedEventStreamConfig_;
00065 errStrConfig = requestedErrorStreamConfig_;
00066 dwParams = requestedDiskWritingParams_;
00067 runNumber = requestedRunNumber_;
00068 timeoutValue = requestedTimeout_;
00069 }
00070
00071 streamChangeInProgress_ = true;
00072
00073 return true;
00074 }
00075
00076 void DiskWriterResources::waitForStreamChange()
00077 {
00078 boost::mutex::scoped_lock sl(streamChangeMutex_);
00079 if (streamChangeIsNeeded_ || streamChangeInProgress_)
00080 {
00081 streamChangeCondition_.wait(sl);
00082 }
00083 }
00084
00085 bool DiskWriterResources::streamChangeOngoing()
00086 {
00087 boost::mutex::scoped_lock sl(streamChangeMutex_);
00088 return (streamChangeIsNeeded_ || streamChangeInProgress_);
00089 }
00090
00091 void DiskWriterResources::streamChangeDone()
00092 {
00093 boost::mutex::scoped_lock sl(streamChangeMutex_);
00094 if (streamChangeInProgress_)
00095 {
00096 streamChangeCondition_.notify_one();
00097 }
00098 streamChangeInProgress_ = false;
00099 }
00100
00101 void DiskWriterResources::setBusy(bool isBusyFlag)
00102 {
00103
00104 diskWriterIsBusy_ = isBusyFlag;
00105 }
00106
00107 bool DiskWriterResources::isBusy()
00108 {
00109
00110 return diskWriterIsBusy_;
00111 }
00112
00113 }
00114