CMS 3D CMS Logo

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