SemaphoreSet.st
changeset 2876 fb3fed7470be
parent 1801 74d0e3858ded
child 5570 e6e14f50d721
equal deleted inserted replaced
2875:54c89acc73ce 2876:fb3fed7470be
    35 
    35 
    36 !
    36 !
    37 
    37 
    38 documentation
    38 documentation
    39 "
    39 "
    40     SemaphoreSets allow waiting until one of several semaphores become available.
    40     SemaphoreSets allow waiting until one of several semaphores becomes available.
    41     They provide a waiting protocol compatible to Semaphore, i.e. #wait and
    41     They provide a waiting protocol which is compatible to Semaphore, 
    42     #waitWithTimeOut.
    42     i.e. #wait and #waitWithTimeOut.
    43 
    43 
    44     [see also:]
    44     [see also:]
    45         Semaphore
    45         Semaphore
    46         Process ProcessorScheduler
    46         Process ProcessorScheduler
    47 
    47 
   202                 false
   202                 false
   203             ]
   203             ]
   204         ] ifNone:[].
   204         ] ifNone:[].
   205     ] valueNowOrOnUnwindDo:[
   205     ] valueNowOrOnUnwindDo:[
   206         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
   206         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
       
   207         self do:[:aSema |
       
   208             aSema unregisterProcess:currentProcess.
       
   209         ]
   207     ].
   210     ].
   208 
   211 
   209     ^ gotSema
   212     ^ gotSema
   210 
   213 
   211     "Modified: 15.12.1995 / 23:10:07 / stefan"
   214     "Modified: 15.12.1995 / 23:10:07 / stefan"
   212     "Modified: 28.2.1996 / 21:25:54 / cg"
   215     "Modified: 20.8.1997 / 18:33:09 / cg"
   213 !
   216 !
   214 
   217 
   215 waitWithTimeout:seconds
   218 waitWithTimeout:seconds
   216     "wait for any of the the semaphore, but abort the wait after some time.
   219     "wait for any of the the semaphore, but abort the wait after some time.
   217      Return the (first) triggered semaphore if any, nil if we return due to a timeout."
   220      Return the (first) triggered semaphore if any, nil if we return due to a timeout."
   261                 false
   264                 false
   262             ]
   265             ]
   263         ] ifNone:[].
   266         ] ifNone:[].
   264     ] valueNowOrOnUnwindDo:[
   267     ] valueNowOrOnUnwindDo:[
   265         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
   268         wasBlocked ifFalse:[OperatingSystem unblockInterrupts].
       
   269         self do:[:aSema |
       
   270             aSema unregisterProcess:currentProcess.
       
   271         ]
   266     ].
   272     ].
   267     ^ gotSema
   273     ^ gotSema
   268 
   274 
   269     "Modified: 15.12.1995 / 23:10:54 / stefan"
   275     "Modified: 15.12.1995 / 23:10:54 / stefan"
   270     "Modified: 28.2.1996 / 21:26:19 / cg"
   276     "Modified: 20.8.1997 / 18:33:23 / cg"
   271 ! !
   277 ! !
   272 
   278 
   273 !SemaphoreSet class methodsFor:'documentation'!
   279 !SemaphoreSet class methodsFor:'documentation'!
   274 
   280 
   275 version
   281 version
   276     ^ '$Header: /cvs/stx/stx/libbasic/SemaphoreSet.st,v 1.10 1996-10-22 19:34:31 cg Exp $'
   282     ^ '$Header: /cvs/stx/stx/libbasic/SemaphoreSet.st,v 1.11 1997-08-20 16:39:12 cg Exp $'
   277 ! !
   283 ! !