org.sonar.api.utils
Interface Semaphores

All Superinterfaces:
BatchComponent, ServerComponent

public interface Semaphores
extends BatchComponent, ServerComponent

A semaphore shared among all the processes that can connect to the central database. It's ignored when enabling the dry run mode.

Since:
3.4

Nested Class Summary
static class Semaphores.Semaphore
           
 
Method Summary
 Semaphores.Semaphore acquire(String name)
          Try to acquire a semaphore.
 Semaphores.Semaphore acquire(String name, int maxDurationInSeconds)
          Try to acquire a semaphore for a given duration.
 void release(String name)
          Release the lock on a semaphore by its name.
 

Method Detail

acquire

Semaphores.Semaphore acquire(String name,
                             int maxDurationInSeconds)
Try to acquire a semaphore for a given duration. The semaphore is acquired if it's unlocked or if the max locking duration is reached.

Parameters:
name - the key of the semaphore
maxDurationInSeconds - the max duration in seconds the semaphore will be acquired. The value zero forces the semaphore to be acquired, whatever its status.
Returns:
the semaphore, whatever its status (locked or unlocked). Can't be null.

acquire

Semaphores.Semaphore acquire(String name)
Try to acquire a semaphore. The lock will be acquired only if there's no existing lock.

Parameters:
name - the key of the semaphore
Returns:
a lock containing information if the lock could be acquired or not, the duration since locked, etc.

release

void release(String name)
Release the lock on a semaphore by its name. Does nothing if the lock is already released.

Parameters:
name - the key of the semaphore


Copyright © 2009-2012 SonarSource. All Rights Reserved.