<--- Cannot embed stylesheet: [Errno 2] No such file or directory: '../../../../aros.css' --->

Semaphore.mui

MUIC_Semaphore

Superclass

rootclass

Description

Provide an object-owned Exec signal semaphore. Construction initializes
the semaphore; the five class methods acquire or release it. The class
declares no attributes and does not add a disposal method.

Keep the object alive while a lock is held or a task is waiting for it.
Arrange object lifetime separately: locking the semaphore does not retain
the BOOPSI object. Finish all uses before disposing of the object.

See Also

MUIM_Semaphore_Attempt, MUIM_Semaphore_AttemptShared,
MUIM_Semaphore_Obtain, MUIM_Semaphore_ObtainShared, MUIM_Semaphore_Release

MUIM_Semaphore_Attempt

Synopsis

IPTR result = DoMethod(obj, MUIM_Semaphore_Attempt);

Function

Try to acquire the object's semaphore exclusively without waiting.

Inputs

obj - Live Semaphore object or subclass instance.
The method message contains only MethodID.

Result

Nonzero if the lock was acquired; zero if it was not.

Notes

Release the lock once after a successful attempt. Do not release it
after a failed attempt. This forwards to exec.library/AttemptSemaphore().

See Also

MUIC_Semaphore, MUIM_Semaphore_Release

MUIM_Semaphore_AttemptShared

Synopsis

IPTR result = DoMethod(obj, MUIM_Semaphore_AttemptShared);

Function

Try to acquire a shared lock without waiting.

Inputs

obj - Live Semaphore object or subclass instance.
The method message contains only MethodID.

Result

Nonzero if the lock was acquired; zero if it was not.

Notes

Other shared holders may coexist. Release once after success and not
after failure. This forwards to exec.library/AttemptSemaphoreShared().

See Also

MUIC_Semaphore, MUIM_Semaphore_Release

MUIM_Semaphore_Obtain

Synopsis

IPTR result = DoMethod(obj, MUIM_Semaphore_Obtain);

Function

Acquire the object's semaphore exclusively, waiting if necessary.

Inputs

obj - Live Semaphore object or subclass instance.
The method message contains only MethodID.

Result

Zero after the lock has been acquired. Zero does not mean failure.

Notes

The call has no timeout or cancellation argument. Call from a task
context in which waiting is permitted. Release each acquisition once.
This forwards to exec.library/ObtainSemaphore().

See Also

MUIC_Semaphore, MUIM_Semaphore_Release

MUIM_Semaphore_ObtainShared

Synopsis

IPTR result = DoMethod(obj, MUIM_Semaphore_ObtainShared);

Function

Acquire a shared lock, waiting if it cannot be obtained immediately.

Inputs

obj - Live Semaphore object or subclass instance.
The method message contains only MethodID.

Result

Zero after the lock has been acquired. Zero does not mean failure.

Notes

Other shared holders may coexist. The call has no timeout or
cancellation argument. Call from a task context in which waiting is
permitted. This forwards to exec.library/ObtainSemaphoreShared().

See Also

MUIC_Semaphore, MUIM_Semaphore_Release

MUIM_Semaphore_Release

Synopsis

IPTR result = DoMethod(obj, MUIM_Semaphore_Release);

Function

Release one acquisition of the object's semaphore.

Inputs

obj - Live Semaphore object or subclass instance.
The method message contains only MethodID.

Result

Zero. This return value is not a lock-state or error indication.

Notes

Match each Obtain, ObtainShared, or successful Attempt/AttemptShared
with one release. Do not release an unheld lock. Waiting tasks may become
runnable. This forwards to exec.library/ReleaseSemaphore().

See Also

MUIM_Semaphore_Obtain, MUIM_Semaphore_ObtainShared