Salome HOME
Python execution management : Lock/Unlock
[modules/superv.git] / src / GraphExecutor / DataFlowExecutor_OutNode.hxx
index fb54a37259d9a525a8d87573ee394b1dfb360ac3..a882cf32bcb8228736553f89453b4b747f828e18 100644 (file)
@@ -1,33 +1,60 @@
-//=============================================================================
-// File      : DataFlowBase_OutNode.hxx
-// Created   : 2002
-// Author    : Jean Rahuel, CEA
-// Project   : SALOME
-// $Header:
-//=============================================================================
+//  SUPERV GraphExecutor : contains classes that permit execution of graphs and particularly the execution automaton
+//
+//  Copyright (C) 2003  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+//  CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS 
+// 
+//  This library is free software; you can redistribute it and/or 
+//  modify it under the terms of the GNU Lesser General Public 
+//  License as published by the Free Software Foundation; either 
+//  version 2.1 of the License. 
+// 
+//  This library is distributed in the hope that it will be useful, 
+//  but WITHOUT ANY WARRANTY; without even the implied warranty of 
+//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU 
+//  Lesser General Public License for more details. 
+// 
+//  You should have received a copy of the GNU Lesser General Public 
+//  License along with this library; if not, write to the Free Software 
+//  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA 
+// 
+//  See http://www.opencascade.org/SALOME/ or email : webmaster.salome@opencascade.org 
+//
+//
+//
+//  File   : DataFlowBase_OutNode.hxx
+//  Author : Jean Rahuel, CEA
+//  Module : SUPERV
+//  $Header:
 
 #ifndef _DATAFLOWEXECUTOR_OUTNODE_HXX
 #define _DATAFLOWEXECUTOR_OUTNODE_HXX
 
 #include "SALOME_Component_i.hxx"
 
-#include "DataFlowBase_Graph.hxx"
-
 #include "DataFlowExecutor_InNode.hxx"
 
+#include "DataFlowBase_StreamGraph.hxx"
+
 namespace GraphExecutor {
 
-  class OutNode : public GraphBase::Graph {
+//  class OutNode : public GraphBase::Graph {
+  class OutNode : public GraphBase::Base {
 
     private :
 
+      GraphBase::StreamGraph * _StreamGraph ;
+      GraphBase::Graph       * _Graph ;
+
+      int  _Graph_prof_debug ;
+
       bool                    _PyInitialized ;
       bool                    _Valid ;
       bool                    _Executable ;
-      SUPERV::AutomatonState  _State ;
+      GraphExecutor::AutomatonState  _State ;
       SUPERV::ControlState    _ControlState ;
       bool                    _Done ;
 
+      pthread_mutex_t                  _PyMutexWait ;
       pthread_mutex_t                  _MutexWait ;
       pthread_cond_t                   _EventWait ;
       pthread_cond_t                   _JoinWait ;
@@ -36,24 +63,29 @@ namespace GraphExecutor {
       int                              _SuspendedThreads ;
       list< char * >                   _EventNodes ;
       list< GraphExecutor::NodeEvent > _Events ;
-      list< SUPERV::AutomatonState >   _States ;
+      list< GraphExecutor::AutomatonState >   _States ;
 
       bool Valid() ;
       void UnValid() ;
       bool Executable() ;
 
-      bool LoadNodes( const GraphBase::ListOfNodes &aNodes ) ;
-      bool LoadLinks( const GraphBase::ListOfLinks &aLinks ) ;
-      bool LoadDatas( const GraphBase::ListOfLinks &aDatas ) ;
+      bool LoadNodes( const GraphBase::ListOfSNodes &aNodes ) ;
+      bool LoadLinks( const GraphBase::ListOfSLinks &aLinks ) ;
+      bool LoadDatas( const GraphBase::ListOfSLinks &aDatas ) ;
 
       CORBA::ORB_ptr _Orb ;
 
+      // scan (reverse) the _EventNodes queue and leave only 1 (the last one that came) 
+      // event for every node
+      void siftEvents();
+
     public :
   
       OutNode() ;
       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
                const char *DataFlowName ,
-               const char * DebugFileName );
+               const char * DebugFileName ,
+               const SUPERV::KindOfNode aKindOfNode );
       OutNode( CORBA::ORB_ptr ORB, SALOME_NamingService* ptrNamingService ,
                const SALOME_ModuleCatalog::Service& DataFlowService ,
                const char *DataFlowComponentName ,
@@ -69,8 +101,18 @@ namespace GraphExecutor {
                const char * DebugFileName ) ;
       virtual ~OutNode() ;
 
-      bool LoadDataFlow( const GraphBase::SGraph &aDataFlow ) ;
-      bool LoadXml( const char* myFileName ) ;
+      void Set_prof_debug( CORBA::ORB_ptr ORB , const char * DebugFileName ) ;
+      GraphBase::StreamGraph * StreamGraph() {
+                               return _StreamGraph ; } ;
+      GraphBase::StreamGraph * StreamGraph() const {
+                               return _StreamGraph ; } ;
+      GraphBase::Graph * Graph() {
+                         return _Graph ; } ;
+      GraphBase::Graph * Graph() const {
+                         return _Graph ; } ;
+
+      bool LoadDataFlow( const GraphBase::SGraph * aDataFlow ) ;
+//      bool LoadXml( const char* myFileName ) ;
       bool LoadInfo( const GraphBase::SNode &aDataFlowInfo ) ;
 
       GraphExecutor::InNode * AddNode(
@@ -83,18 +125,13 @@ namespace GraphExecutor {
                         const SUPERV::KindOfNode NodeKindOfNode = SUPERV::ComputingNode ,
                         const SUPERV::SDate NodeFirstCreation = SUPERV::SDate() ,
                         const SUPERV::SDate NodeLastModification = SUPERV::SDate() ,
-                        const char * NodeEditorRelease = NULL ,
-                        const char * NodeAuthor = NULL ,
-                        const char * NodeComputer = NULL ,
-                        const char * NodeComment = NULL ,
+                        const char * NodeEditorRelease = NULLSTRING ,
+                        const char * NodeAuthor = NULLSTRING ,
+                        const char * NodeComputer = NULLSTRING ,
+                        const char * NodeComment = NULLSTRING ,
                         const int NodeX = 0 ,
                         const int NodeY = 0 ) ;
 
-      bool AddInputData( const char* ToNodeName1 ,
-                         const char* ToParameterName1 ,
-                         const char* ToNodeName2 ,
-                         const char* ToParameterName2 ) ;
-
       bool IsValid() { if ( !_Valid )
                          return Valid() ;
                        return _Valid ; } ;
@@ -115,22 +152,25 @@ namespace GraphExecutor {
 
       void PThreadLock( pthread_mutex_t * aMutex , char * errmsg ) ;
       void PThreadUnLock( pthread_mutex_t * aMutex , char * errmsg ) ;
-      void PThreadLock() ;
-      void PThreadUnLock() ;
+      void PyThreadLock() ;
+      void PyThreadUnLock() ;
 
       void NewThread() ;
-      void ExitThread() ;
+      void ExitThread( pthread_t ThreadNumber = 0 ) ;
       void SuspendThread() ;
       void ResumeThread() ;
       long Threads() { return _Threads ; } ;
       long SuspendedThreads() { return _SuspendedThreads ; } ;
       void JoinedWait() ;
 
+      pthread_t ThreadNo() {
+                return _Graph->ThreadNo() ; } ;
       long Thread( const char * NodeName ) ;
 
       bool PushEvent( GraphExecutor::InNode * aNode ,
                       GraphExecutor::NodeEvent anEvent ,
-                      SUPERV::AutomatonState aState ) ;
+                      GraphExecutor::AutomatonState aState ) ;
+      int GetListSize();
       bool StateWait( SUPERV::GraphState aState ) ;
       bool Event( char ** aNodeName ,
                   SUPERV::GraphEvent & anEvent ,
@@ -142,9 +182,13 @@ namespace GraphExecutor {
       bool EventWait( char ** aNodeName ,
                       SUPERV::GraphEvent & anEvent ,
                       SUPERV::GraphState & aState ) ;
+      long EventQSize() ;
+      void EventList() ;
+
+      void SendSomeDataReady( const char * aNodeName ) ;
 
-      void State(SUPERV::AutomatonState aState ) ;
-      const char * StateName(SUPERV::AutomatonState aState ) {
+      void State(GraphExecutor::AutomatonState aState ) ;
+      const char * StateName(GraphExecutor::AutomatonState aState ) {
              return theAutomaton->StateName( aState ) ; }
 
       SUPERV::GraphState State() ;
@@ -153,10 +197,10 @@ namespace GraphExecutor {
                                 const char * ServiceParameterName ) ;
 
       SUPERV::GraphEvent AutomatonGraphEvent(GraphExecutor::NodeEvent anEvent) ;
-      SUPERV::GraphState AutomatonGraphState(SUPERV::AutomatonState anAutomatonState) ;
+      SUPERV::GraphState AutomatonGraphState(GraphExecutor::AutomatonState anAutomatonState) ;
 
-      SUPERV::AutomatonState AutomatonState() ;
-      SUPERV::AutomatonState AutomatonState( const char * NodeName ) ;
+      GraphExecutor::AutomatonState AutomatonState() ;
+      GraphExecutor::AutomatonState AutomatonState( const char * NodeName ) ;
 
       SUPERV::ControlState ControlState() ;
       SUPERV::ControlState ControlState( const char * aNodeName ) ;
@@ -172,11 +216,11 @@ namespace GraphExecutor {
       bool ReRun() ;
       bool ReStart() ;
 
-      void Done( bool aDone ) { _Done = aDone ; } ;
-
       bool IsWaiting() ;
       bool IsReady() ;
       bool IsRunning() ;
+      void Done( bool aDone ) { _Done = aDone ; } ;
+      bool Done() { return _Done ; } ;
       bool IsDone() ;
       bool IsSuspended() ;
       bool IsKilled() ;
@@ -203,6 +247,8 @@ namespace GraphExecutor {
                                    const char *ToParameterName ) ;
       const CORBA::Any *GetOutData( const char *FromNodeName ,
                                     const char *FromParameterName ) ;
+      const long CpuUsed() ;
+      const long CpuUsed( const char *aNodeName ) ;
   };
 };