A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://docs.racket-lang.org/reference/semaphore.html below:

11.2.3 Semaphores

11.2.3 Semaphores🔗ℹ

A semaphore has an internal counter; when this counter is zero, the semaphore can block a thread’s execution (through semaphore-wait) until another thread increments the counter (using semaphore-post). The maximum value for a semaphore’s internal counter is platform-specific, but always at least 10000.

A semaphore’s counter is updated in a single-threaded manner, so that semaphores can be used for reliable synchronization. Semaphore waiting is fair: if a thread is blocked on a semaphore and the semaphore’s internal value is non-zero infinitely often, then the thread is eventually unblocked.

In addition to its use with semaphore-specific procedures, a semaphore can be used as a synchronizable event (see Events). A semaphore is ready for synchronization when semaphore-wait would not block. Upon synchronization, the semaphore’s counter is decremented, and the synchronization result of a semaphore is the semaphore itself.

Returns

#t

if

v

is a

semaphore

,

#f

otherwise.

Creates and returns a new semaphore with the counter initially set to

init

. If

init

is larger than a semaphore’s maximum internal counter value, the

exn:fail

exception is raised.

Increments the semaphore’s internal counter and returns

#<void>

. If the semaphore’s internal counter has already reached its maximum value, the

exn:fail

exception is raised.

Blocks until the internal counter for semaphore

sema

is non-zero. When the counter is non-zero, it is decremented and

semaphore-wait

returns

#<void>

.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4