SharedQueue.st
changeset 1 85d662a8509f
parent 0 1cf8d1747859
child 3 c9936b5a86a1
equal deleted inserted replaced
0:1cf8d1747859 1:85d662a8509f
    88 nextPut:anObject
    88 nextPut:anObject
    89     "enter anObject into the queue; wait for available space, if
    89     "enter anObject into the queue; wait for available space, if
    90      the queue is full. After the put, signal availablity of a datum
    90      the queue is full. After the put, signal availablity of a datum
    91      to readers."
    91      to readers."
    92 
    92 
    93     |value ok|
    93     |ok|
    94 
    94 
    95     ok := false.
    95     ok := false.
    96     [ok] whileFalse:[
    96     [ok] whileFalse:[
    97         [tally == contentsArray size] whileTrue:[
    97         [tally == contentsArray size] whileTrue:[
    98             spaceAvailable wait
    98             spaceAvailable wait
   115     ^ anObject
   115     ^ anObject
   116 ! !
   116 ! !
   117 
   117 
   118 !SharedQueue methodsFor:'queries'!
   118 !SharedQueue methodsFor:'queries'!
   119 
   119 
   120 isEmpty
   120 size
   121     ^ tally == 0
   121     "return the number of elements in the shared queue"
   122 !
       
   123 
   122 
   124 size
       
   125     ^ tally
   123     ^ tally
   126 ! !
   124 ! !