diff -r f0d934fe881b -r 63fc2acb417a Process.st --- a/Process.st Wed Sep 04 12:53:41 2002 +0200 +++ b/Process.st Wed Sep 04 13:45:52 2002 +0200 @@ -16,7 +16,8 @@ instanceVariableNames:'id suspendContext prio state startBlock name restartable interruptActions exitActions suspendSemaphore singleStepping emergencySignalHandler suspendActions creatorId processGroupId - interruptsDisabled priorityRange exceptionHandlerSet processType environment' + interruptsDisabled priorityRange exceptionHandlerSet processType + environment' classVariableNames:'TerminateSignal RestartSignal CoughtSignals' poolDictionaries:'' category:'Kernel-Processes' @@ -1892,9 +1893,45 @@ "Created: 28.10.1996 / 20:44:07 / cg" ! ! +!Process methodsFor:'thread local storage'! + +threadVariableValueOf:aKey + "return the value of a thread local variable, or nil if no such variable exists" + + |val| + + environment isNil ifTrue:[^ nil]. + val := environment at:aKey ifAbsent:[nil]. + ^ val value. +! + +withThreadVariable:variableNameSymbol boundTo:aValue do:aBlock + |var oldValue result| + + 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. + result := aBlock value. + ] ensure:[ + oldValue isNil + ifTrue:[ environment removeKey:variableNameSymbol] + ifFalse:[ var value:oldValue ] + ]. + ^ result +! ! + !Process class methodsFor:'documentation'! version - ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.128 2002-09-04 10:53:41 cg Exp $' + ^ '$Header: /cvs/stx/stx/libbasic/Process.st,v 1.129 2002-09-04 11:45:52 cg Exp $' ! ! Process initialize!