--- a/Semaphore.st Tue Jun 25 14:22:06 2019 +0200
+++ b/Semaphore.st Tue Jun 25 14:26:25 2019 +0200
@@ -1117,7 +1117,8 @@
"wait for the semaphore, but abort the wait after some time (seconds).
return the receiver if the semaphore triggered normal, nil if we return
due to a timeout.
- The seconds-argument may be a float (i.e. use 0.1 for a 100ms timeout).
+ The argument may be a time duration or the number of seconds as integer
+ or float (i.e. use 0.1 for a 100ms timeout).
With zero timeout, this can be used to poll a semaphore (returning
the receiver if the semaphore is available, nil if not).
However, polling is not the intended use of semaphores, though.
@@ -1139,9 +1140,10 @@
^ self waitUncountedWithTimeoutMs:millis state:#wait.
"Created: / 15-04-2019 / 12:12:52 / Stefan Vogel"
+ "Modified (comment): / 25-06-2019 / 14:25:52 / Claus Gittinger"
!
-waitUncountedWithTimeoutMs:milliSeconds
+waitUncountedWithTimeoutMs:milliSecondsOrNil
"wait for the semaphore; do not consume the resource
(i.e. do not count down).
Abort the wait after some time.
@@ -1150,18 +1152,19 @@
With zero timeout, this can be used to poll a semaphore (returning
the receiver if the semaphore is available, nil if not).
However, polling is not the intended use of semaphores, though.
- If milliSeconds is nil, wait without timeout."
+ If milliSecondsOrNil is nil, wait without timeout."
<resource: #skipInDebuggersWalkBack>
- self waitUncountedWithTimeoutMs:milliSeconds state:#wait
+ self waitUncountedWithTimeoutMs:milliSecondsOrNil state:#wait
"Modified: / 13-12-1995 / 13:27:24 / stefan"
"Modified: / 24-07-2017 / 21:53:57 / cg"
"Modified: / 30-05-2018 / 13:57:16 / Claus Gittinger"
+ "Modified (comment): / 25-06-2019 / 14:24:26 / Claus Gittinger"
!
-waitUncountedWithTimeoutMs:milliSeconds state:newStateSymbol
+waitUncountedWithTimeoutMs:milliSecondsOrNil state:newStateSymbol
"wait for the semaphore; do not consume the resource
(i.e. do not count down).
Abort the wait after some time.
@@ -1170,7 +1173,7 @@
With zero timeout, this can be used to poll a semaphore
(returning the receiver if the semaphore is available, nil if not).
However, polling is not the intended use of semaphores, though.
- If milliSeconds is nil, wait without timeout.
+ If milliSecondsOrNil is nil, wait without timeout.
The stateSymbol argument is purely for the ProcessMonitor, to present a nicer
threadState (#wait instead of #suspend)"
@@ -1186,7 +1189,7 @@
count <= 0 ifTrue:[
"with zero-timeout, this is a poll"
- milliSeconds == 0 ifTrue:[
+ milliSecondsOrNil == 0 ifTrue:[
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
^ nil
].
@@ -1194,10 +1197,10 @@
activeProcess := Processor activeProcess.
timeoutOccurred := false.
- milliSeconds notNil ifTrue:[
+ milliSecondsOrNil notNil ifTrue:[
"Wait with timeout: calculate the end-time"
maxMilliseconds := SmallInteger maxVal // 4.
- currentDelta := milliSeconds.
+ currentDelta := milliSecondsOrNil.
currentDelta > maxMilliseconds ifTrue:[
"NOTE: the microsecondTime is increasing monotonically,
while millisecondTime is wrapping at 16r1fffffff.
@@ -1277,7 +1280,7 @@
"Modified: / 24-07-2017 / 23:06:00 / cg"
"Modified: / 02-08-2017 / 14:16:08 / stefan"
"Modified: / 30-05-2018 / 13:57:11 / Claus Gittinger"
- "Modified (comment): / 25-06-2019 / 07:55:03 / Claus Gittinger"
+ "Modified (comment): / 25-06-2019 / 14:24:18 / Claus Gittinger"
!
waitWithTimeout:secondsOrNilOrTimeDuration
@@ -1314,7 +1317,7 @@
"Modified (comment): / 25-06-2019 / 14:21:43 / Claus Gittinger"
!
-waitWithTimeoutMs:milliSeconds
+waitWithTimeoutMs:milliSecondsOrNil
"wait for the semaphore, but abort the wait after some time.
return the receiver if the semaphore triggered normal, nil if we return
due to a timeout.
@@ -1323,20 +1326,21 @@
However, polling is not the intended use of semaphores, though.
If milliSeconds is nil, wait without timeout."
- ^ self waitWithTimeoutMs:milliSeconds state:#wait
+ ^ self waitWithTimeoutMs:milliSecondsOrNil state:#wait
"Modified: / 21-02-2017 / 15:21:30 / stefan"
"Modified: / 24-07-2017 / 21:15:25 / cg"
+ "Modified (format): / 25-06-2019 / 14:26:12 / Claus Gittinger"
!
-waitWithTimeoutMs:milliSeconds state:waitStateSymbol
+waitWithTimeoutMs:milliSecondsOrNil state:waitStateSymbol
"wait for the semaphore, but abort the wait after some time.
return the receiver if the semaphore triggered normal, nil if we return
due to a timeout.
With zero timeout, this can be used to poll a semaphore (returning
the receiver if the semaphore is available, nil if not).
However, polling is not the intended use of semaphores, though.
- If milliSeconds is nil, wait without timeout.
+ If milliSecondsOrNil is nil, wait without timeout.
THIS IS A COPY of #waitWithTimeoutMs - the only difference is setting waitStateSymbol.
waitStateSymbol is the state the process is set to while waiting - normally #wait."
@@ -1347,7 +1351,7 @@
count <= 0 ifTrue:[
"with zero-timeout, this is a poll"
- milliSeconds == 0 ifTrue:[
+ milliSecondsOrNil == 0 ifTrue:[
wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
^ nil
].
@@ -1355,10 +1359,10 @@
activeProcess := Processor activeProcess.
timeoutOccurred := false.
- milliSeconds notNil ifTrue:[
+ milliSecondsOrNil notNil ifTrue:[
"Wait with timeout: calculate the end-time"
maxMilliseconds := SmallInteger maxVal // 4.
- currentDelta := milliSeconds.
+ currentDelta := milliSecondsOrNil.
currentDelta > maxMilliseconds ifTrue:[
"NOTE: the microsecondTime is increasing monotonically,
while millisecondTime is wrapping at 16r1fffffff.
@@ -1441,6 +1445,7 @@
"Modified: / 24-07-2017 / 23:04:57 / cg"
"Modified: / 02-08-2017 / 14:16:48 / stefan"
+ "Modified (comment): / 25-06-2019 / 14:23:42 / Claus Gittinger"
! !
!Semaphore class methodsFor:'documentation'!