Constructor

@:has_untyped@:keepnew(value:Int)

Creates a new semaphore with an initial value.

Methods

@:has_untyped@:keepacquire():Void

Locks the semaphore. If the value of the semaphore is zero, then the thread will block until it is able to lock the semaphore. If the value is non-zero, it is decreased by one.

@:has_untyped@:keeprelease():Void

Release the semaphore. The value of the semaphore is increased by one.

@:has_untyped@:keeptryAcquire(?timeout:Float):Bool

Try to lock the semaphore. If the value of the semaphore is zero, false is returned, else the value is increased.

If timeout is specified, this function will block until the thread is able to acquire the semaphore, or the timout expires. timeout is in seconds.