Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:12:11

0001 // -*- C++ -*-
0002 //
0003 // Package:     FWCore/Framework
0004 // Class  :     LuminosityBlockProcessingStatus
0005 //
0006 // Implementation:
0007 //     [Notes on implementation]
0008 //
0009 // Original Author:  Chris Jones
0010 //         Created:  Thu, 11 Jan 2018 16:41:46 GMT
0011 //
0012 
0013 #include "LuminosityBlockProcessingStatus.h"
0014 #include "FWCore/Framework/interface/LuminosityBlockPrincipal.h"
0015 
0016 namespace edm {
0017   void LuminosityBlockProcessingStatus::resetResources() {
0018     endIOVWaitingTasks_.doneWaiting(std::exception_ptr{});
0019     for (auto& iter : eventSetupImpls_) {
0020       iter.reset();
0021     }
0022     resumeGlobalLumiQueue();
0023   }
0024 
0025   void LuminosityBlockProcessingStatus::setGlobalEndRunHolder(WaitingTaskHolder holder) {
0026     globalEndRunHolder_ = std::move(holder);
0027   }
0028 
0029   bool LuminosityBlockProcessingStatus::shouldStreamStartLumi() {
0030     if (state_ == State::kNoMoreEvents)
0031       return false;
0032 
0033     bool changed = false;
0034     do {
0035       auto expected = State::kRunning;
0036       changed = state_.compare_exchange_strong(expected, State::kUpdating);
0037       if (expected == State::kNoMoreEvents)
0038         return false;
0039     } while (changed == false);
0040 
0041     ++nStreamsProcessingLumi_;
0042     state_ = State::kRunning;
0043     return true;
0044   }
0045 
0046   void LuminosityBlockProcessingStatus::noMoreEventsInLumi() {
0047     bool changed = false;
0048     do {
0049       auto expected = State::kRunning;
0050       changed = state_.compare_exchange_strong(expected, State::kUpdating);
0051       assert(expected != State::kNoMoreEvents);
0052     } while (changed == false);
0053     nStreamsStillProcessingLumi_.store(nStreamsProcessingLumi_);
0054     state_ = State::kNoMoreEvents;
0055   }
0056 
0057   void LuminosityBlockProcessingStatus::setEndTime() {
0058     constexpr char kUnset = 0;
0059     constexpr char kSetting = 1;
0060     constexpr char kSet = 2;
0061 
0062     if (endTimeSetStatus_ != kSet) {
0063       //not already set
0064       char expected = kUnset;
0065       if (endTimeSetStatus_.compare_exchange_strong(expected, kSetting)) {
0066         lumiPrincipal_->setEndTime(endTime_);
0067         endTimeSetStatus_.store(kSet);
0068       } else {
0069         //wait until time is set
0070         while (endTimeSetStatus_.load() != kSet) {
0071         }
0072       }
0073     }
0074   }
0075 }  // namespace edm