Eiffel Media API
Overview Cluster Class Classes Index      Previous Next      Top Features

em.thread

Class EM_SEMAPHORE


Direct ancestors

SDL_MUTEX_FUNCTIONS_EXTERNAL, DISPOSABLE

Creation

Features

Invariants

indexing

description

*** Since Eiffel doesn't correctly support threats, this doesn't work yet ***

A semaphore that can control access to shared ressources.

date

$Date: 2005/10/26 12:19:15 $

revision

$Revision: 1.11 $

class

EM_SEMAPHORE

create

make (an_initial_value :INTEGER)

-- Creates a semaphore with an_initial_value.

feature -- Commands

try_wait: BOOLEAN

-- Attempts to lock the semaphore but does not suspend the calling thread.
-- Returns True if the semaphore was locked successfully. In this case the
-- semaphore value was automatically decreased.
-- Returns False if the semaphore could not be locked or an error occured.

unlock

-- Releases the lock on the semaphore and increments the semaphore value.

unlock_if_locked

-- Releases the lock on the semaphore only if its value is currently 0.

wait

-- Locks the semaphore and suspends the calling thread if the semaphore value is zero.
-- This call will automatically decrease the semaphore value.

wait_timeout (a_timeout : INTEGER) : BOOLEAN

-- Locks the semaphore, but only wait up to a specific maximum time.
-- a_timeout is the maximum wait time in miliseconds.
-- You should not use this feature if possible, because on some
-- platforms it is implemented by active waiting (spinning).
-- Returns True if the lock was successful. In this case the semaphore
-- value was automatically decreased.
-- Returns False if a timeout or error occured.

feature -- Information

value: INTEGER

-- Returns the current value of the semaphore.

invariant


-- From ANY
reflexive_equality: standard_is_equal (Current)
reflexive_conformance: conforms_to (Current)

end