Class AsynchronousSemaphore
java.lang.Object
com.codingchili.core.benchmarking.AsynchronousSemaphore
An asynchronous semaphore.
This implementation does not make sure that a principal releasing a permit actually owned the permit.
-
Constructor Summary
ConstructorDescriptionAsynchronousSemaphore(CoreContext context, int limit)
Creates a new asynchronous semaphore. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Acquires a permit from the semaphore when ones becomes available.void
release()
Returns a permit to the semaphore without checking that the principal returning a permit actually owns a permit.
-
Constructor Details
-
AsynchronousSemaphore
Creates a new asynchronous semaphore.- Parameters:
context
- the context on which the semaphore operates.limit
- the maximum number of permits to allow concurrently.
-
-
Method Details
-
acquire
Acquires a permit from the semaphore when ones becomes available. If the timeout is expired while waiting the future will fail.- Parameters:
handler
- the handler to be called when a permit is received.timeoutMS
- the maximum time to wait for a permit.
-
release
public void release()Returns a permit to the semaphore without checking that the principal returning a permit actually owns a permit.
-