CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_3/src/EventFilter/StorageManager/src/DQMEventProcessorResources.cc

Go to the documentation of this file.
00001 // $Id: DQMEventProcessorResources.cc,v 1.5 2011/03/07 15:31:32 mommsen Exp $
00003 
00004 #include "EventFilter/StorageManager/interface/DQMEventProcessorResources.h"
00005 
00006 namespace stor
00007 {
00008   DQMEventProcessorResources::DQMEventProcessorResources() :
00009   requestsPending_(false),
00010   requestsInProgress_(false)
00011   {
00012     pendingRequests_.reset();
00013   }
00014   
00015   void DQMEventProcessorResources::
00016   requestConfiguration(DQMProcessingParams const& params, boost::posix_time::time_duration const& timeoutValue)
00017   {
00018     boost::mutex::scoped_lock sl(requestsMutex_);
00019 
00020     requestedDQMProcessingParams_ = params;
00021     requestedTimeout_ = timeoutValue;
00022 
00023     // A new configuration forces the store destruction and
00024     // after the store is destroyed, end-of-run processing
00025     // has nothing left to do. Thus, cancel these requests.
00026     pendingRequests_.configuration = true;
00027     pendingRequests_.endOfRun = false;
00028     pendingRequests_.storeDestruction = false;
00029     requestsPending_ = true;
00030   }
00031 
00032   void DQMEventProcessorResources::requestEndOfRun()
00033   {
00034     boost::mutex::scoped_lock sl(requestsMutex_);
00035 
00036     // A end-of-run request does not change any other requests.
00037     pendingRequests_.endOfRun = true;
00038     requestsPending_ = true;
00039   }
00040 
00041   void DQMEventProcessorResources::requestStoreDestruction()
00042   {
00043     boost::mutex::scoped_lock sl(requestsMutex_);
00044 
00045     // The store destruction clears everything.
00046     // Thus, cancel any other pending requests.
00047     pendingRequests_.configuration = false;
00048     pendingRequests_.endOfRun = false;
00049     pendingRequests_.storeDestruction = true;
00050     requestsPending_ = true;
00051   }
00052 
00053   bool DQMEventProcessorResources::
00054   getRequests(Requests& requests, DQMProcessingParams& params, boost::posix_time::time_duration& timeoutValue)
00055   {
00056     boost::mutex::scoped_lock sl(requestsMutex_);
00057 
00058     if (! requestsPending_) {return false;}
00059 
00060     requestsPending_ = false;
00061 
00062     requests = pendingRequests_;
00063     params = requestedDQMProcessingParams_;
00064     timeoutValue = requestedTimeout_;
00065 
00066     pendingRequests_.reset();
00067     requestsInProgress_ = true;
00068 
00069     return true;
00070   }
00071 
00072   void DQMEventProcessorResources::waitForCompletion()
00073   {
00074     boost::mutex::scoped_lock sl(requestsMutex_);
00075     if (requestsPending_ || requestsInProgress_)
00076       {
00077         requestsCondition_.wait(sl);
00078       }
00079   }
00080 
00081   bool DQMEventProcessorResources::requestsOngoing()
00082   {
00083     boost::mutex::scoped_lock sl(requestsMutex_);
00084     return (requestsPending_ || requestsInProgress_);
00085   }
00086 
00087   void DQMEventProcessorResources::requestsDone()
00088   {
00089     boost::mutex::scoped_lock sl(requestsMutex_);
00090     if (requestsInProgress_)
00091       {
00092         requestsCondition_.notify_one();
00093       }
00094     requestsInProgress_ = false;
00095   }
00096 
00097   void DQMEventProcessorResources::Requests::reset()
00098   {
00099     configuration = false;
00100     endOfRun = false;
00101     storeDestruction = false;
00102   }
00103 
00104 } // namespace stor
00105