HierarchicalList.st
changeset 2223 c34e7fd25e53
parent 1961 86effae0802b
child 2231 65cec3d10fb1
--- a/HierarchicalList.st	Thu Sep 26 10:51:17 2002 +0200
+++ b/HierarchicalList.st	Thu Sep 26 20:49:13 2002 +0200
@@ -15,7 +15,7 @@
 
 List subclass:#HierarchicalList
 	instanceVariableNames:'recursionLock root showRoot application monitoringTask
-		monitoringTaskDelay'
+		monitoringTaskDelay additionalItemsToMonitorSemaphore'
 	classVariableNames:''
 	poolDictionaries:''
 	category:'Views-Support'
@@ -271,19 +271,25 @@
 !
 
 startMonitoringTask
-    "start the monitoring task; success only if dependencies exists
+    "start the monitoring task; backgrund process finishes, when no (more) dependencies exist,
+     and the additionalItemsToMonitorSemaphore is not signalled (aka: no more background children to read)
     "
     |name|
 
     (     monitoringTask isNil
      and:[monitoringTaskDelay notNil
-     and:[dependents size ~~ 0]]
+     and:[(dependents size ~~ 0) or:[additionalItemsToMonitorSemaphore notNil]]]
     ) ifTrue:[
         monitoringTask := [
-            [dependents size ~~ 0] whileTrue:[
+            |nextItem|
+            [(dependents size ~~ 0) or:[additionalItemsToMonitorSemaphore notNil]] whileTrue:[
                 self monitoringCycle.
-                Delay waitForSeconds:(self monitoringTaskDelay)
-            ]
+                additionalItemsToMonitorSemaphore isNil ifTrue:[
+                    Delay waitForSeconds:monitoringTaskDelay
+                ] ifFalse:[
+                    additionalItemsToMonitorSemaphore waitWithTimeout:(self monitoringTaskDelay)
+                ]
+            ].
         ] forkAt:4.
 
         name := application notNil ifTrue:[application class name] ifFalse:['???'].
@@ -305,6 +311,23 @@
             task waitUntilTerminated.
         ]
     ]
+!
+
+triggerUpdateCycle
+    additionalItemsToMonitorSemaphore isNil ifTrue:[
+        [
+            additionalItemsToMonitorSemaphore isNil ifTrue:[
+                additionalItemsToMonitorSemaphore := Semaphore new.
+            ].
+        ] valueUninterruptably
+    ].
+
+    monitoringTaskDelay isNil ifTrue:[
+        monitoringTaskDelay := 10
+    ].
+
+    additionalItemsToMonitorSemaphore signalOnce.
+    self startMonitoringTask.
 ! !
 
 !HierarchicalList methodsFor:'protocol'!
@@ -340,5 +363,5 @@
 !HierarchicalList class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalList.st,v 1.11 2001-04-03 06:46:36 ca Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg2/HierarchicalList.st,v 1.12 2002-09-26 18:49:13 penk Exp $'
 ! !