Brooklyn

brooklyn.util.mutex
[Java] Interface WithMutexes


public interface WithMutexes

interface which allows multiple callers to co-operate using named mutexes, inspectably, and containing implementation as inner class

MutexSupport is a common implementation of this. mixin code frequently delegates to this, as shown in the test case's WithMutexesTest.SampleWithMutexesDelegatingMixin class


Method Summary
void acquireMutex(java.lang.String mutexId, java.lang.String description)

acquires a mutex, if available, otherwise blocks on its becoming available; caller must release after use

boolean hasMutex(java.lang.String mutexId)

returns true if the calling thread has the mutex with the given ID

void releaseMutex(java.lang.String mutexId)

releases a mutex, triggering another thread to use it or cleaning it up if no one else is waiting; this should only be called by the mutex owner (thread)

boolean tryAcquireMutex(java.lang.String mutexId, java.lang.String description)

acquires a mutex and returns true, if available; otherwise immediately returns false; caller must release after use if this returns true

 

Method Detail

acquireMutex

public void acquireMutex(java.lang.String mutexId, java.lang.String description)
acquires a mutex, if available, otherwise blocks on its becoming available; caller must release after use


hasMutex

public boolean hasMutex(java.lang.String mutexId)
returns true if the calling thread has the mutex with the given ID


releaseMutex

public void releaseMutex(java.lang.String mutexId)
releases a mutex, triggering another thread to use it or cleaning it up if no one else is waiting; this should only be called by the mutex owner (thread)


tryAcquireMutex

public boolean tryAcquireMutex(java.lang.String mutexId, java.lang.String description)
acquires a mutex and returns true, if available; otherwise immediately returns false; caller must release after use if this returns true


 

Brooklyn Multi-Cloud Application Management Platform
brooklyncentral.github.com. Apache License. © 2012.