CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Stopping.cc
Go to the documentation of this file.
1 // $Id: Stopping.cc,v 1.9.6.1 2011/03/07 11:33:05 mommsen Exp $
3 
10 
11 #include <iostream>
12 #include <unistd.h>
13 
14 using namespace std;
15 using namespace stor;
16 
17 Stopping::Stopping( my_context c ): my_base(c)
18 {
20 }
21 
23 {
24 
25  TransitionRecord tr( stateName(), true );
26  outermost_context().updateHistory( tr );
27 
28  SharedResourcesPtr sharedResources =
29  outermost_context().getSharedResources();
30 
31  // request that the streams that are currently configured in the disk
32  // writer be destroyed (this has the side effect of closing files)
33  sharedResources->diskWriterResources_->requestStreamDestruction();
34 
35  // request that the DQM event store is cleared
36  // if FinishingDQM has succeeded, the store is already empty
37  sharedResources->dqmEventProcessorResources_->requestStoreDestruction();
38 }
39 
41 {
43 }
44 
46 {
47  TransitionRecord tr( stateName(), false );
48  outermost_context().updateHistory( tr );
49 }
50 
51 string Stopping::do_stateName() const
52 {
53  return std::string( "Stopping" );
54 }
55 
57 {
58  outermost_context().getSharedResources()->moveToFailedState( exception );
59 }
60 
61 void Stopping::logHaltDoneRequest( const HaltDone& request )
62 {
63  outermost_context().unconsumed_event( request );
64 }
65 
66 void
68 {
69  if ( destructionIsDone() )
70  {
71  SharedResourcesPtr sharedResources =
72  outermost_context().getSharedResources();
73  EventPtr_t stMachEvent( new StopDone() );
74  sharedResources->commandQueue_->enqWait( stMachEvent );
75  }
76 }
77 
78 bool
80 {
81  SharedResourcesPtr sharedResources =
82  outermost_context().getSharedResources();
83 
84  // check if the requests are still being processed
85  if ( sharedResources->diskWriterResources_->streamChangeOngoing() ) return false;
86 
87  if ( sharedResources->dqmEventProcessorResources_->requestsOngoing() ) return false;
88 
89  return true;
90 }
91 
92 
virtual std::string do_stateName() const
Definition: Stopping.cc:51
std::string stateName() const
Definition: Operations.cc:39
bool destructionIsDone() const
Definition: Stopping.cc:79
boost::shared_ptr< SharedResources > SharedResourcesPtr
boost::shared_ptr< boost::statechart::event_base > EventPtr_t
Definition: CommandQueue.h:21
void safeExitAction()
Definition: Operations.cc:108
virtual void do_noFragmentToProcess() const
Definition: Stopping.cc:67
virtual void do_exitActionWork()
Definition: Stopping.cc:45
void logHaltDoneRequest(const HaltDone &request)
Definition: Stopping.cc:61
virtual ~Stopping()
Definition: Stopping.cc:40
virtual void do_entryActionWork()
Definition: Stopping.cc:22
virtual void do_moveToFailedState(xcept::Exception &exception) const
Definition: Stopping.cc:56
void safeEntryAction()
Definition: Operations.cc:77