Salome HOME
ValidSwitchs
authorrahuel <rahuel@opencascade.com>
Wed, 9 Mar 2005 09:25:43 +0000 (09:25 +0000)
committerrahuel <rahuel@opencascade.com>
Wed, 9 Mar 2005 09:25:43 +0000 (09:25 +0000)
Debug of flushing of events
State --> PortState and Done --> PortDone ==> Lisibility

src/GraphExecutor/DataFlowExecutor_OutNode.cxx

index e143daabe3be55c00c8df8107b305b104a6e2798..1f123d73aed0a0254d2d0618a69f8989b71542c0 100644 (file)
@@ -463,20 +463,24 @@ bool GraphExecutor::OutNode::Valid() {
   if ( Graph()->IsDataStreamNode() ) {
     StreamGraph()->SubStreamGraphsNumber( SubStreamGraphsNumber ) ;
   }
+  Graph()->InLineServices() ;
+
   if ( !Graph()->ValidLoops() ) {
     cdebug_out << "This DataFlow have not valid Loops." << endl ;
     return false ;
   }
+  if ( !Graph()->ValidSwitchs() ) {
+    cdebug_out << "This DataFlow have not valid Switchs." << endl ;
+    return false ;
+  }
 
 //  CreateService() ;
 
-  Graph()->InLineServices() ;
-
   Graph()->ComputingNodes() ;
   
   _Valid = true ;
 
-  cdebug_out << "GraphExecutor::OutNode::Valid" << endl;
+  cdebug_out << "GraphExecutor::OutNode::Valid " << _Valid << endl;
   return _Valid ;
 }
 
@@ -591,6 +595,7 @@ bool GraphExecutor::OutNode::Run( const bool AndSuspend ) {
 //                   GraphExecutor::DataReadyState ) ; 
 // We say that we have to create a thread for that HeadNode 'anInNode'
         anInNode->CreateNewThread( true ) ;
+        IncrCreatedThreads() ;
         anInNode->DataFromNode( Graph()->Name() ) ;
 // AndSuspend == true <==> Start()
         if ( AndSuspend ) {
@@ -743,8 +748,17 @@ void GraphExecutor::OutNode::CheckAllDone() {
              << EventQSize() << endl  ;
     cdebug << "================================================================================" << endl ;
 
+//JR 23.02.2005, Debug : siftEvents() must be inside the pthread_mutex_lock
+    if ( pthread_mutex_lock( &_MutexWait ) ) {
+      perror("EventLoop pthread_mutex_lock ") ;
+      exit( 0 ) ;
+    }
     // asv : fix for 6798 and other bugs: "sift" the event queue after execution
     siftEvents();
+    if ( pthread_mutex_unlock( &_MutexWait ) ) {
+      perror("PushEvent pthread_mutex_unlock ") ;
+      exit( 0 ) ;
+    }
 
     // asv : 25.10.04 : calling Editing() to indicate stop of execution
     Graph()->GraphEditor()->Editing();
@@ -1213,15 +1227,15 @@ bool GraphExecutor::OutNode::PushEvent( GraphExecutor::InNode * aNode ,
   }
 //  cdebug_out << "PushEvent Threads " << Threads() << " SuspendedThreads "
 //             << SuspendedThreads() << endl ;
-#if 0
-  if ( _EventNodes.size() > 101 ) {
-    while ( _EventNodes.size() > 31 ) {
-      _EventNodes.pop_front() ;
-      _Events.pop_front() ;
-      _States.pop_front() ;
-    }
+
+//JR 21.02.2005 Debug : old events should be removed at creation time for python-clients
+  int EventNodesSize = _EventNodes.size() ;
+  if ( _EventNodes.size() > (unsigned int)Graph()->GraphNodesSize()*70 ) {
+    siftEvents();
+    cdebug << "OutNode::PushEvent " << _EventNodes.size() << " in queue instead of "
+           << EventNodesSize << endl ;
   }
-#endif
+
   if ( pthread_mutex_unlock( &_MutexWait ) ) {
     perror("PushEvent pthread_mutex_unlock ") ;
     exit( 0 ) ;
@@ -1237,10 +1251,16 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName ,
                                     SUPERV::GraphEvent & anEvent ,
                                     SUPERV::GraphState & aState ,
                                     bool WithWait ) {
+//JR 23.02.2005, Debug : siftEvents() must be inside the pthread_mutex_lock
+  if ( pthread_mutex_lock( &_MutexWait ) ) {
+    perror("EventLoop pthread_mutex_lock ") ;
+    exit( 0 ) ;
+  }
   // asv : fixing problem of loops with large number of iterations (>5000)
   // experimentally was found that number of non-handled by GUI events = (number_of_nodes x 7)
   // or 7 events for each node - so what we want to do here is remove "old" events for nodes
   // "on the fly".  Once again it is done in Stop(), Kill(), Done() functions.
+  int EventNodessize = _EventNodes.size() ;
   if ( _EventNodes.size() > (unsigned int)Graph()->GraphNodesSize()*7 )
     siftEvents();
 
@@ -1248,13 +1268,10 @@ bool GraphExecutor::OutNode::Event( char ** aNodeName ,
   int SuspendedThreadsNumber ;
   bool cdebuginout = false ;
   if ( _EventNodes.size() > 0 ) {
-//    cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue" << endl ;
+    cdebug_in << "GraphExecutor::OutNode::Event " << _EventNodes.size() << " in queue instead of "
+              << EventNodessize << endl ;
     cdebuginout = true ;
   }
-  if ( pthread_mutex_lock( &_MutexWait ) ) {
-    perror("EventLoop pthread_mutex_lock ") ;
-    exit( 0 ) ;
-  }
   _JustStarted = false ;
   ThreadsNumber = Threads() ;
   SuspendedThreadsNumber = SuspendedThreads() ;
@@ -1709,8 +1726,8 @@ bool GraphExecutor::OutNode::IsSuspended( const char * NodeName ) {
   return aret ;
 }
 
-bool GraphExecutor::OutNode::IsDone( const char * NodeName ,
-                                     const char * ServiceParameterName )  {
+bool GraphExecutor::OutNode::PortDone( const char * NodeName ,
+                                       const char * ServiceParameterName )  {
 //  cdebug_in << "GraphExecutor::OutNode::IsDone " << NodeName << " "
 //            << ServiceParameterName<< endl;
   bool aret = Graph()->PortDone( NodeName , ServiceParameterName ) ;
@@ -1905,8 +1922,17 @@ bool GraphExecutor::OutNode::Kill() {
              << " Threads " << _Threads << " SuspendedThreads " << _SuspendedThreads
              << " EventQSize " << EventQSize() << endl ;
 
+  if ( pthread_mutex_lock( &_MutexWait ) ) {
+    perror("EventLoop pthread_mutex_lock ") ;
+    exit( 0 ) ;
+  }
+//JR 23.02.2005, Debug : siftEvents() must be inside the pthread_mutex_lock
   // remove "extra" events from the event queue
   siftEvents();
+  if ( pthread_mutex_unlock( &_MutexWait ) ) {
+    perror("PushEvent pthread_mutex_unlock ") ;
+    exit( 0 ) ;
+  }
 
   // asv : 25.10.04 : calling Editing() to indicate stop of execution
   Graph()->GraphEditor()->Editing();