Destroys all data for the semaphore.
Destroys all data for the semaphore. Any instances blocking for a permit will be released and return as Failure,
Attempts to release a permit.
Attempts to release a permit. If this instance is not holding a permit this function call does nothing
@return Success if managed to access Consul, then true if a permit was released.
The Consul session ID for this Semaphore instance
The Consul session ID for this Semaphore instance
1.0.0
Attempts to acquire a permit blocking if necessary.
Attempts to acquire a permit blocking if necessary. If this instance is already holding a permit no further permits are taken
The deadline for when to give up blocking for a permit
Success if managed to access Consul, then true if a permit was acquired.
Attempts to acquire a permit blocking if necessary.
Attempts to acquire a permit blocking if necessary. If this instance is already holding a permit no further permits are taken In practice this invokes
tryAcquire(Deadline.now + maxWait)
The maximum time to block for a permit
Success if managed to access Consul, then true if a permit was acquired.
Attempts to acquire a permit without blocking.
Attempts to acquire a permit without blocking. If this instance is already holding a permit no further permits are taken
Success if managed to access Consul, then true if a permit was acquired.
(Since version ) see corresponding Javadoc for more information.
A semaphore is a construction to control access to a common resource in a concurrent system. The semaphore in this library allows for creation of a distributed lock. In principle a semaphore is initiated with 1..n permits, instances of a semaphore then try to acquire one permit either succeeding or failing in case there are no more permits left to take. The simplest form is a binary semaphore which has only one permit thus only allowing a single instance to acquire a permit. Semaphores are traditionally used to control access to a protected source like a database or some task that only should be executed by a single process.
Each instance of the Semaphore class can hold exactly 0 or 1 permit thus invoking any of the tryAcquire functions mulitple times will not acquire additional permits.