eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'EventSemaphore':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: EventSemaphore


Inheritance:

   Object
   |
   +--AbstractLock
      |
      +--Semaphore
         |
         +--EventSemaphore

Package:
stx:libbasic
Category:
Kernel-Processes
Version:
rev: 1.9 date: 2021/01/20 12:58:21
user: cg
file: EventSemaphore.st directory: libbasic
module: stx stc-classLibrary: libbasic

Description:


Processes wait for an EventSemaphores until it is signaled.
The EventSemaphore is not consumed and remains signaled until manually reset.

copyright

COPYRIGHT (c) 2016 by eXept Software AG All Rights Reserved This software is furnished under a license and may be used only in accordance with the terms of that license and with the inclusion of the above copyright notice. This software may not be provided or otherwise made available to, or used by, any other person. No title to or ownership of the software is hereby transferred.

example

Create an event and signal it. After being signaled, the waiter on the event returns immediately. [exBegin] |event| event := EventSemaphore new. [ event wait. Transcript showCR:'Process 1 continued' ] forkAt:9. [ event wait. Transcript showCR:'Process 2 continued' ] forkAt:9. event signal. event wait. event wait. [exEnd]

Class protocol:

signaling
o  new: n
count must be 0 or 1


Instance protocol:

blocked
o  signalForAll
blocked, since it would only set the event if there was anyone waiting

o  signalIf
blocked, since it would only set the event if there was anyone waiting

misc
o  reset
reset the event to the non-signaled state

semaphoreSet interface
o  checkAndAddWaitingProcess: process
interface for SemaphoreSet.
If the semaphore is available, return true.
Otherwise register our process to be wakened up once the semaphore is available
and return false.
ATTENTION: this must be invoked with OperatingSystem-interrupts-blocked.

signaling
o  signal
redefined to limit count to 1

waiting
o  wait
once signaled, do not decrement the count

o  waitWithTimeoutMs: milliSeconds state: newState
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.

Redefined: once signaled, do not decrement the count



ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Mon, 07 Oct 2024 23:04:37 GMT