ccs.beetree
Class GlobalMutex

java.lang.Object
  extended by ccs.beetree.GlobalMutex

public class GlobalMutex
extends java.lang.Object

A nestable, inter-VM global mutex. Mutexes access to a beetree disk file by using NIO file locking on a secondary lock file ~cpoint/lock/fileID.lock where fileID is the beetree file ID. Note that this mutex is only suitable for locking out other processes; to lock out other threads within the current VM requires something else. Mostly for BeeLock's use, but public just in case it may be useful elsewhere.


Constructor Summary
GlobalMutex(long fileID)
           
 
Method Summary
 long getFileID()
           
 long getWriteGate()
          Obtain the current global write gate.
 boolean isLocked()
           
 void lock()
           
 void setWriteGate(long newgate)
          Sets the global write-gate to the specified value.
 void unlock()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

GlobalMutex

public GlobalMutex(long fileID)
Method Detail

getFileID

public long getFileID()

lock

public void lock()
          throws java.io.IOException
Throws:
java.io.IOException

isLocked

public boolean isLocked()

getWriteGate

public long getWriteGate()
Obtain the current global write gate. Only available when locked.


setWriteGate

public void setWriteGate(long newgate)
                  throws java.io.IOException
Sets the global write-gate to the specified value. Only available when locked.

Throws:
java.io.IOException

unlock

public void unlock()
            throws java.io.IOException
Throws:
java.io.IOException