CMS 3D CMS Logo

VisQueueProcessor.cc

Go to the documentation of this file.
00001 //<<<<<< INCLUDES                                                       >>>>>>
00002 
00003 #include "VisFramework/VisFrameworkBase/interface/VisQueueProcessor.h"
00004 #include "VisFramework/VisFrameworkBase/interface/VisQueue.h"
00005 #include "VisFramework/VisFrameworkBase/interface/debug.h"
00006 #include "Utilities/Threads/interface/Thread.h"
00007 #include <classlib/utils/Signal.h>
00008 #include <classlib/utils/Callback.h>
00009 #include <qapplication.h> // FIXME: move out
00010 
00011 //<<<<<< PRIVATE DEFINES                                                >>>>>>
00012 //<<<<<< PRIVATE CONSTANTS                                              >>>>>>
00013 //<<<<<< PRIVATE TYPES                                                  >>>>>>
00014 //<<<<<< PRIVATE VARIABLE DEFINITIONS                                   >>>>>>
00015 //<<<<<< PUBLIC VARIABLE DEFINITIONS                                    >>>>>>
00016 //<<<<<< CLASS STRUCTURE INITIALIZATION                                 >>>>>>
00017 
00018 IG_DEFINE_STATE_ELEMENT (VisQueueProcessor,
00019                          "Services/Framework/Elements/QueueProcessor");
00020 
00021 //<<<<<< PRIVATE FUNCTION DEFINITIONS                                   >>>>>>
00022 //<<<<<< PUBLIC FUNCTION DEFINITIONS                                    >>>>>>
00023 //<<<<<< MEMBER FUNCTION DEFINITIONS                                    >>>>>>
00024 
00026 VisQueueProcessor::VisQueueProcessor (IgState *state)
00027     : m_state (state),
00028       m_done (false),
00029       m_dispatcher (new VisEventDispatcher ())
00030 {
00031     LOG (0, trace, LFfwvis, "VisQueueProcessor::VisQueueProcessor\n");
00032     ASSERT (m_state); m_state->put (s_key, this); 
00033 }
00034 
00036 VisQueueProcessor::~VisQueueProcessor (void)
00037 { ASSERT (m_state); m_state->detach (s_key); }
00038 
00039 VisQueueProcessor::VisEventDispatcher
00040 VisQueueProcessor::eventDispatcher (void)
00041 {
00042     return *m_dispatcher;
00043 }
00044 
00046 
00090 void
00091 VisQueueProcessor::process (void)
00092 {
00093     LOG (0, trace, LFfwvis, "VisQueueProcessor::process()\n");
00094 
00095     // Force our signal handler until we can get decent tracebacks
00096     // from COBRA in case of error.  This kills the Objy handlers so
00097     // it isn't a nice approach...
00098     lat::Signal::handleFatal("iguana");
00099 
00100     // FIXME: Move out -- another lazy observer that observes event?
00101     qApp->lock ();
00102     QApplication::restoreOverrideCursor ();
00103     qApp->unlock (false);
00104 
00105     // Pull items off the queue and execute them until we are told to
00106     // stop.  Abort throws an exception so we don't need to care.
00107     VisQueue *q = VisQueue::get (m_state);
00108     ASSERT (q);
00109 
00110     for (m_done = false; ! m_done; )
00111     {
00112         lat::Callback action (q->pop ());
00113         LOG (0, trace, LFfwvis, "VisQueueProcessor: got action\n");
00114         action ();
00115     }
00116 
00117     LOG (0, trace, LFfwvis, "VisQueueProcessor: loop done\n"); 
00118 
00119     // FIXME: Move out -- another observer that observes end-of-event?
00120     // FIXME: Block GUI.  FIXME: Needs unsetting for end-of-run.
00121     qApp->lock ();
00122     QApplication::setOverrideCursor (Qt::waitCursor);
00123     qApp->unlock (false);
00124 
00125     LOG (0, trace, LFfwvis, "VisQueueProcessor::process() done\n");
00126 }
00127 
00129 
00133 void
00134 VisQueueProcessor::scheduleAbort (void)
00135 {
00136     ASSERT (VisQueue::get (m_state));
00137     VisQueue::get (m_state)
00138         ->push (lat::CreateCallback (this, &VisQueueProcessor::doAbort));
00139 }
00140 
00146 void
00147 VisQueueProcessor::scheduleNextEvent (void)
00148 {
00149     LOG (0, trace, LFfwvis, "VisQueueProcessor::scheduleNextEvent()\n");
00150 
00151     ASSERT (VisQueue::get (m_state));
00152     VisQueue::get (m_state)
00153         ->push (lat::CreateCallback (this, &VisQueueProcessor::doNextEvent));
00154 
00155     LOG (0, trace, LFfwvis, "VisQueueProcessor::scheduleNextEvent() done\n");
00156 }
00157 
00159 
00160 void
00161 VisQueueProcessor::doAbort (void)
00162 { 
00163     //throw FIXME::SomeExceptionTypeHere (); 
00164 }
00165 
00168 void
00169 VisQueueProcessor::doNextEvent (void)
00170 {
00171     LOG (0, trace, LFfwvis, "VisQueueProcessor::doNextEvent()\n");
00172 
00173     VisEventMessage event;
00174     
00175     eventDispatcher ().broadcast (event);
00176     m_done = true;
00177 
00178     LOG (0, trace, LFfwvis, "VisQueueProcessor::doNextEvent() done\n");
00179 }

Generated on Tue Jun 9 17:50:04 2009 for CMSSW by  doxygen 1.5.4