예제 #1
0
 void
 sigTerm (Subsys* susy, string* problem) ///< called from subsystem on termination
   {
     REQUIRE (susy);
     Lock sync (this);
     triggerEmergency(!isnil (problem));
     INFO (subsystem, "Subsystem '%s' terminated.", cStr(*susy));
     WARN_IF (!isnil(problem), subsystem, "Irregular shutdown caused by: %s", cStr(*problem));
     ERROR_IF (susy->isRunning(), subsystem, "Subsystem '%s' signals termination, "
                                             "without resetting running state", cStr(*susy));
     removeall (running_, susy);
     shutdownAll();
     sync.notify();
   }
예제 #2
0
 virtual void
 run (Arg) 
   {
     // Prepare an (test)Index (dummy "session")
     PPIdx testSession (build_testScopes());
     
     ElementQuery queryAPI;
     
     MORef<DummyMO> dummy1 = queryAPI.pick (elementID_contains("MO2"));
     CHECK (dummy1);
     CHECK (dummy1->isValid());
     INFO  (test, "Location in Tree: %s", cStr(ScopePath(dummy1.getPlacement())));
     
     string elementID = dummy1->operator string();
     CHECK (contains (elementID, "MO2"));
     
     string specificID = elementID.substr(10);   // should contain the random int-ID
     MORef<DummyMO> dummy2;
     CHECK (!dummy2);
     dummy2 = queryAPI.pick (elementID_contains(specificID));
     CHECK (dummy2);                         // found the same object again
     CHECK (dummy2->isValid());
     CHECK (dummy2 == dummy1);
     
     
     // put aside a new handle holding onto the MObject
     PDum newPlacement(dummy1.getPlacement());
     CHECK (testSession->contains(dummy1));
     CHECK (!testSession->contains(newPlacement));
     
     // and now remove the placement and all contained elements
     testSession->clear (dummy1);
     CHECK (!testSession->contains(dummy1));
     
     MORef<DummyMO> findAgain = queryAPI.pick (elementID_contains(specificID));
     CHECK (!findAgain);     // empty result because searched element was removed from session...
     
     MORef<DummyMO> otherElm = queryAPI.pick (elementID_contains("MO21"));
     CHECK (otherElm);    // now pick just some other arbitrary element 
     
     testSession->insert(newPlacement, otherElm);
     dummy2 = queryAPI.pick (elementID_contains(specificID));
     CHECK (dummy2);
     CHECK (dummy2 != dummy1);
     CHECK (dummy2 != newPlacement);
     CHECK (isSharedPointee(newPlacement, dummy2.getPlacement()));
     CHECK (Scope::containing (dummy2.getRef()) == Scope (otherElm));
     INFO  (test, "New treelocation: %s", cStr(ScopePath(dummy2.getPlacement())));
   }
예제 #3
0
 /** finish and leave child object scope, return to parent */
 void
 TreeDiffMutatorBinding::emu (GenNode const& n)
 {
   TRACE (diff, "tree-diff: LEAVE scope %s", cStr(n.idi));
   
   __expect_end_of_scope (n.idi);
   treeMutator_ = &scopeManger_->closeScope();
   __expect_valid_parent_scope (n.idi);
 }
예제 #4
0
 /** open nested scope to apply diff to child object */
 void
 TreeDiffMutatorBinding::mut (GenNode const& n)
 {
   TreeMutator::Handle buffHandle = scopeManger_->openScope();      // hint: treeMutatorSize(...)
   if (not treeMutator_->mutateChild(n, buffHandle))
     __failMismatch("enter nested scope", n);
   
   TRACE (diff, "tree-diff: ENTER scope %s", cStr(n.idi));
   treeMutator_ = buffHandle.get();
 }
예제 #5
0
 void
 triggerStartup (Subsys* susy)
   {
     REQUIRE (susy);
     if (susy->isRunning()) return;
     
     INFO (subsystem, "Triggering startup of subsystem \"%s\"", cStr(*susy));
     
     for_each (susy->getPrerequisites(), start_);
     bool started = susy->start (opts_, bind (&SubsystemRunner::sigTerm, this, susy, _1));
     
     if (started)
       {
         if (susy->isRunning())
           running_.push_back (susy); // now responsible for managing the started subsystem
         else
           throw error::Logic("Subsystem "+string(*susy)+" failed to start");
       }
     
     if (!and_all (susy->getPrerequisites(), isRunning() ))
       {
         susy->triggerShutdown();
         throw error::State("Unable to start all prerequisites of Subsystem "+string(*susy));
   }   }