@@ -679,169 +679,4 @@ namespace edm {
679679
680680 bool AliasProductResolver::singleProduct_ () const { return true ; }
681681
682- SwitchBaseProductResolver::SwitchBaseProductResolver (std::shared_ptr<ProductDescription const > bd,
683- DataManagingOrAliasProductResolver& realProduct)
684- : realProduct_(realProduct), productData_(std::move(bd)), prefetchRequested_(false ) {
685- // Parentage of this branch is always the same by construction, so we can compute the ID just "once" here.
686- Parentage p;
687- p.setParents (std::vector<BranchID>{realProduct.productDescription ().originalBranchID ()});
688- parentageID_ = p.id ();
689- ParentageRegistry::instance ()->insertMapped (p);
690- }
691-
692- void SwitchBaseProductResolver::connectTo (ProductResolverBase const & iOther, Principal const * iParentPrincipal) {
693- throw Exception (errors::LogicError)
694- << " SwitchBaseProductResolver::connectTo() not implemented and should never be called.\n "
695- << " Contact a Framework developer\n " ;
696- }
697-
698- void SwitchBaseProductResolver::setupUnscheduled (UnscheduledConfigurator const & iConfigure) {
699- worker_ = iConfigure.findWorker (productDescription ().moduleLabel ());
700- }
701-
702- ProductResolverBase::Resolution SwitchBaseProductResolver::resolveProductImpl (Resolution res) const {
703- if (res.data () == nullptr )
704- return res;
705- return Resolution (&productData_);
706- }
707-
708- bool SwitchBaseProductResolver::productResolved_ () const {
709- // SwitchProducer will never put anything in the event, and
710- // "false" will make Event::commit_() to call putProduct() with
711- // null unique_ptr<WrapperBase> to signal that the produce() was
712- // run.
713- return false ;
714- }
715-
716- void SwitchBaseProductResolver::setProductProvenanceRetriever_ (ProductProvenanceRetriever const * provRetriever) {
717- productData_.setProvenance (provRetriever);
718- }
719-
720- void SwitchBaseProductResolver::setProductID_ (ProductID const & pid) {
721- // insertIntoSet is const, so let's exploit that to fake the getting of the "input" product
722- productData_.setProductID (pid);
723- }
724-
725- void SwitchBaseProductResolver::resetProductData_ (bool deleteEarly) {
726- productData_.resetProductData ();
727- realProduct_.resetProductData_ (deleteEarly);
728- if (not deleteEarly) {
729- prefetchRequested_ = false ;
730- waitingTasks_.reset ();
731- }
732- }
733-
734- void SwitchBaseProductResolver::unsafe_setWrapperAndProvenance () const {
735- // update provenance
736- productData_.provenance ().store ()->insertIntoSet (ProductProvenance (productDescription ().branchID (), parentageID_));
737- // Use the Wrapper of the pointed-to resolver, but the provenance of this resolver
738- productData_.unsafe_setWrapper (realProduct ().getProductData ().sharedConstWrapper ());
739- }
740-
741- SwitchProducerProductResolver::SwitchProducerProductResolver (std::shared_ptr<ProductDescription const > bd,
742- DataManagingOrAliasProductResolver& realProduct)
743- : SwitchBaseProductResolver(std::move(bd), realProduct), status_(defaultStatus_) {}
744-
745- ProductResolverBase::Resolution SwitchProducerProductResolver::resolveProduct_ (
746- Principal const & principal, SharedResourcesAcquirer* sra, ModuleCallingContext const * mcc) const {
747- if (status_ == ProductStatus::ResolveFailed) {
748- return resolveProductImpl (realProduct ().resolveProduct (principal, sra, mcc));
749- }
750- return Resolution (nullptr );
751- }
752-
753- void SwitchProducerProductResolver::prefetchAsync_ (WaitingTaskHolder waitTask,
754- Principal const & principal,
755- ServiceToken const & token,
756- SharedResourcesAcquirer* sra,
757- ModuleCallingContext const * mcc) const noexcept {
758- if (productDescription ().availableOnlyAtEndTransition () and mcc and not mcc->parent ().isAtEndTransition ()) {
759- return ;
760- }
761-
762- // need to try changing prefetchRequested before adding to waitingTasks
763- bool expected = false ;
764- bool doPrefetchRequested = prefetchRequested ().compare_exchange_strong (expected, true );
765- waitingTasks ().add (waitTask);
766-
767- if (doPrefetchRequested) {
768- // using a waiting task to do a callback guarantees that
769- // the waitingTasks() list will be released from waiting even
770- // if the module does not put this data product or the
771- // module has an exception while running
772- auto waiting = make_waiting_task ([this ](std::exception_ptr const * iException) {
773- if (nullptr != iException) {
774- waitingTasks ().doneWaiting (*iException);
775- } else {
776- unsafe_setWrapperAndProvenance ();
777- waitingTasks ().doneWaiting (std::exception_ptr ());
778- }
779- });
780- worker ()->callWhenDoneAsync (WaitingTaskHolder (*waitTask.group (), waiting));
781- }
782- }
783-
784- void SwitchProducerProductResolver::putProduct (std::unique_ptr<WrapperBase> edp) const {
785- if (status_ != defaultStatus_) {
786- throw Exception (errors::InsertFailure)
787- << " Attempt to insert more than one product for a branch " << productDescription ().branchName ()
788- << " This makes no sense for SwitchProducerProductResolver.\n Contact a Framework developer" ;
789- }
790- // Let's use ResolveFailed to signal that produce() was called, as
791- // there is no real product in this resolver
792- status_ = ProductStatus::ResolveFailed;
793- bool expected = false ;
794- if (prefetchRequested ().compare_exchange_strong (expected, true )) {
795- unsafe_setWrapperAndProvenance ();
796- waitingTasks ().doneWaiting (std::exception_ptr ());
797- }
798- }
799-
800- bool SwitchProducerProductResolver::productUnavailable_ () const {
801- // if produce() was run (ResolveFailed), ask from the real resolver
802- if (status_ == ProductStatus::ResolveFailed) {
803- return realProduct ().productUnavailable ();
804- }
805- return true ;
806- }
807-
808- void SwitchProducerProductResolver::resetProductData_ (bool deleteEarly) {
809- SwitchBaseProductResolver::resetProductData_ (deleteEarly);
810- if (not deleteEarly) {
811- status_ = defaultStatus_;
812- }
813- }
814-
815- ProductResolverBase::Resolution SwitchAliasProductResolver::resolveProduct_ (Principal const & principal,
816- SharedResourcesAcquirer* sra,
817- ModuleCallingContext const * mcc) const {
818- return resolveProductImpl (realProduct ().resolveProduct (principal, sra, mcc));
819- }
820-
821- void SwitchAliasProductResolver::prefetchAsync_ (WaitingTaskHolder waitTask,
822- Principal const & principal,
823- ServiceToken const & token,
824- SharedResourcesAcquirer* sra,
825- ModuleCallingContext const * mcc) const noexcept {
826- // need to try changing prefetchRequested_ before adding to waitingTasks_
827- bool expected = false ;
828- bool doPrefetchRequested = prefetchRequested ().compare_exchange_strong (expected, true );
829- waitingTasks ().add (waitTask);
830-
831- if (doPrefetchRequested) {
832- // using a waiting task to do a callback guarantees that
833- // the waitingTasks() list will be released from waiting even
834- // if the module does not put this data product or the
835- // module has an exception while running
836- auto waiting = make_waiting_task ([this ](std::exception_ptr const * iException) {
837- if (nullptr != iException) {
838- waitingTasks ().doneWaiting (*iException);
839- } else {
840- unsafe_setWrapperAndProvenance ();
841- waitingTasks ().doneWaiting (std::exception_ptr ());
842- }
843- });
844- realProduct ().prefetchAsync (WaitingTaskHolder (*waitTask.group (), waiting), principal, token, sra, mcc);
845- }
846- }
847682} // namespace edm
0 commit comments