Process.st
changeset 25244 6df56799dd3e
parent 25222 2140d86c8d42
--- a/Process.st	Wed Feb 05 17:23:19 2020 +0100
+++ b/Process.st	Wed Feb 05 17:24:31 2020 +0100
@@ -644,26 +644,29 @@
     |lowPri hiPri newPrio|
 
     priorityRange := anInterval.
-    anInterval notNil ifTrue:[
-	lowPri := priorityRange start.
-	hiPri := priorityRange stop.
-	(newPrio := prio) isNil ifTrue:[
-	    newPrio := lowPri
-	] ifFalse:[
-	    prio < lowPri ifTrue:[
-		newPrio := lowPri
-	    ] ifFalse:[
-		prio > hiPri ifTrue:[
-		    newPrio := hiPri
-		].
-	    ].
-	].
-	newPrio ~~ prio ifTrue:[
-	    self priority:newPrio
-	]
+    anInterval isNil ifTrue:[
+        ^ self.
     ].
-
-    "Modified: / 3.8.1998 / 22:56:05 / cg"
+    
+    lowPri := priorityRange start.
+    hiPri := priorityRange stop.
+    (newPrio := prio) isNil ifTrue:[
+        newPrio := lowPri
+    ] ifFalse:[
+        prio < lowPri ifTrue:[
+            newPrio := lowPri
+        ] ifFalse:[
+            prio > hiPri ifTrue:[
+                newPrio := hiPri
+            ].
+        ].
+    ].
+    newPrio ~~ prio ifTrue:[
+        self priority:newPrio
+    ]
+
+    "Modified: / 03-08-1998 / 22:56:05 / cg"
+    "Modified: / 05-02-2020 / 16:33:30 / Stefan Vogel"
 !
 
 processGroupId
@@ -2268,27 +2271,26 @@
 	]
 !
 
-environmentAt:aKey ifAbsent:defaultValue
+environmentAt:aKey ifAbsent:aBlock
     "return the value of a thread local variable, or the value of defaultValue if no such variable exists"
 
-    |val|
-
-    environment isNil ifTrue:[^ defaultValue value].
-    val := environment at:aKey ifAbsent:[^ defaultValue value].
-    ^ val value.
+    environment isNil ifTrue:[
+        ^ aBlock value
+    ].
+    ^ environment at:aKey ifAbsent:aBlock.
+
+    "Modified: / 05-02-2020 / 16:51:35 / Stefan Vogel"
 !
 
 environmentAt:aKey put:aValue
     "set the value of a thread local variable. Returns aValue"
 
-    |var|
-
     environment isNil ifTrue:[
         environment := IdentityDictionary new
     ].
-    var := environment at:aKey ifAbsentPut:[ValueHolder new].
-    var value:aValue.
-    ^ aValue
+    ^ environment at:aKey put:aValue.
+
+    "Modified: / 05-02-2020 / 16:52:33 / Stefan Vogel"
 !
 
 environmentIncludesKey:aKey
@@ -2355,49 +2357,43 @@
      By default, this is Transcript, but it can be overwritten
      (for example to redirect a thread's output to some other place"
 
-    ^ self environmentAt:#Transcript ifAbsent:[Transcript]
+    ^ self environmentAt:#Transcript ifAbsent:Transcript.
+
+    "Modified: / 05-02-2020 / 17:11:14 / Stefan Vogel"
 !
 
 withThreadLocalVariables:aDictionary do:aBlock
     "evaluate a block with threadLocalVariables from aDictionary;
      restore the old bindings afterwards."
 
-    |oldEnv result|
+    |oldEnv|
 
     oldEnv := environment.
-
-    [
-	environment := aDictionary.
-	result := aBlock value.
-    ] ensure:[
-	environment := oldEnv.
+    environment := aDictionary.
+
+    ^ aBlock ensure:[
+        environment := oldEnv.
     ].
-    ^ result
+
+    "Modified: / 05-02-2020 / 16:29:08 / Stefan Vogel"
 !
 
 withThreadVariable:variableNameSymbol boundTo:aValue do:aBlock
     "evaluate a block with the threadLocalVariable being bound to aValue;
      undo the variable binding afterwards."
 
-    |var oldValue|
+    |oldValue|
 
     environment isNil ifTrue:[
         environment := IdentityDictionary new
     ].
-    var := environment at:variableNameSymbol ifAbsent:nil.
-    var isNil ifTrue:[
-        var := ValueHolder new.
-        environment at:variableNameSymbol put:var.
-    ].
-
-    oldValue := var value.
-    ^ [
-        var value:aValue.
-        aBlock value.
-    ] ensure:[
-        oldValue isNil
+    oldValue := environment at:variableNameSymbol ifAbsent:Void.
+    environment at:variableNameSymbol put:aValue.
+    
+    ^ aBlock ensure:[
+        oldValue == Void
             ifTrue:[ environment removeKey:variableNameSymbol]
-            ifFalse:[ var value:oldValue ]
+            ifFalse:[ environment at:variableNameSymbol put:oldValue ]
     ].
 
     "
@@ -2423,7 +2419,7 @@
             ]
     "
 
-    "Modified: / 05-06-2018 / 16:41:11 / Stefan Vogel"
+    "Modified: / 05-02-2020 / 16:50:19 / Stefan Vogel"
 ! !
 
 !Process class methodsFor:'documentation'!