#REFACTORING by cg
class: Semaphore
added: #setCount:name:
class: Semaphore class
added: #name:
changed: #forMutualExclusion
--- a/Semaphore.st Tue Aug 08 19:43:51 2017 +0200
+++ b/Semaphore.st Wed Aug 09 11:50:52 2017 +0200
@@ -1,5 +1,3 @@
-"{ Encoding: utf8 }"
-
"
COPYRIGHT (c) 1993 by Claus Gittinger
All Rights Reserved
@@ -321,10 +319,18 @@
Also see RecursionLock, to avoid deadlock in case of recursive entered
critical regions."
- ^ self basicNew setCount:1; name:'criticalRegionSema'
+ ^ self basicNew setCount:1 name:'criticalRegionSema'
+
+ "Modified: / 18-02-2017 / 17:27:14 / stefan"
+ "Modified: / 09-08-2017 / 11:50:15 / cg"
+!
- "Modified: / 17-06-1998 / 16:23:09 / cg"
- "Modified: / 18-02-2017 / 17:27:14 / stefan"
+name:aString
+ "create & return a new semaphore which blocks until a signal is sent"
+
+ ^ self basicNew setCount:0 name:aString
+
+ "Created: / 09-08-2017 / 11:49:18 / cg"
!
new
@@ -540,6 +546,17 @@
count := n
"Modified: 17.2.1997 / 11:36:40 / cg"
+!
+
+setCount:n name:aString
+ "set the count of the semaphore;
+ that's the number of possible waits, without blocking"
+
+ waitingProcesses := nil.
+ count := n.
+ name := aString.
+
+ "Created: / 09-08-2017 / 11:48:00 / cg"
! !
!Semaphore methodsFor:'queries'!