org.terracotta.locking
Interface GenericLockStrategy<L,K>

All Known Subinterfaces:
LockStrategy<K>
All Known Implementing Classes:
BasicLockStrategy, HashcodeLockStrategy, LongLockStrategy, NullLockStrategy, OneToOneLockStrategy

public interface GenericLockStrategy<L,K>

Author:
Chris Dennis

Method Summary
 void beginLock(L lockID, int type)
          Called to acquire a lock on the given lockId at the given level.
 void commitLock(L lockID, int type)
          Called to release a lock on the given lockId held at the given level.
 L generateLockIdForKey(String instanceQualifier, K key)
          Generate the lock identifier to be used when performing operations for the given key.
 void pinLock(L lockID)
          Called to indicate that the associated lock might be required frequently.
 boolean tryBeginLock(L lockID, int type, long nanos)
          Called to attempt to acquire a lock on the given lockId at the given level.
 void unpinLock(L lockID)
          Called to indicate that the associated lock is no longer required frequently.
 

Method Detail

generateLockIdForKey

L generateLockIdForKey(String instanceQualifier,
                       K key)
Generate the lock identifier to be used when performing operations for the given key.

To prevent inter-map lock collisions the instanceQualifier provided by the caller should be used to form the key.

Parameters:
instanceQualifier - A unique identifier for the map being operated on.
key - key to be locked
Returns:
lock identifier

beginLock

void beginLock(L lockID,
               int type)
Called to acquire a lock on the given lockId at the given level.

Parameters:
lockID - lock to lock
type - hold type to acquire

pinLock

void pinLock(L lockID)
Called to indicate that the associated lock might be required frequently.

This call can be used to help guide resource allocation and collection.

Parameters:
lockId - lock to `pin'

unpinLock

void unpinLock(L lockID)
Called to indicate that the associated lock is no longer required frequently.

This call can be used to help guide resource allocation and collection.

Parameters:
lock - lock to `unpin'

commitLock

void commitLock(L lockID,
                int type)
Called to release a lock on the given lockId held at the given level.

Parameters:
lockID - lock to unlock
type - hold type to release

tryBeginLock

boolean tryBeginLock(L lockID,
                     int type,
                     long nanos)
                     throws InterruptedException
Called to attempt to acquire a lock on the given lockId at the given level.

Parameters:
lockID - lock to lock
type - hold type to acquire
time - to wait for lock in nanoseconds
Throws:
InterruptedException


Copyright © 2015 Terracotta, Inc.. All Rights Reserved.