pt.ua.concurrent
Interface Sync

All Superinterfaces:
InterruptibleAwaitingThreads
All Known Implementing Classes:
GroupMutex, Mutex, RWEx

public interface Sync
extends InterruptibleAwaitingThreads

Java's interface for locks.

This class follows DbC(tm) methodology (Wikipedia). Where possible, contracts are implement with native's Java assert.

Version:
0.5, October 2013
Author:
Miguel Oliveira e Silva (mos@ua.pt)

Method Summary
 SyncState getStateAndUnlock()
          Get current Sync state, and unlock it (if applicable).
 boolean lockIsMine()
          Is lock owned by me?
 SyncCV newCV()
          Create and return a new condition variable attached to current Sync.
 void recoverState(SyncState state)
          Recover Sync state.
 
Methods inherited from interface pt.ua.concurrent.InterruptibleAwaitingThreads
interruptWaitingThreads, registerAwaitingThreads
 

Method Detail

lockIsMine

boolean lockIsMine()
Is lock owned by me?

Returns:
true, if lock is mine

newCV

SyncCV newCV()
Create and return a new condition variable attached to current Sync.

Returns:
the new condition variable

getStateAndUnlock

SyncState getStateAndUnlock()
Get current Sync state, and unlock it (if applicable). (Internal service).

Precondition:
lockIsMine()

Returns:
the Sync state object.

recoverState

void recoverState(SyncState state)
                  throws ThreadInterruptedException
Recover Sync state. (Internal service).

Precondition:
state != null && state.obj() == this - my state object required
!lockIsMine()

Parameters:
state - Sync state object (returned by getStateAndUnlock)
Throws:
ThreadInterruptedException