public class LockManager extends Object implements ILockManager
| Modifier and Type | Field and Description |
|---|---|
static String |
_rcsid |
protected ILockManager |
lockManager
Backing lock manager
|
| Constructor and Description |
|---|
LockManager() |
| Modifier and Type | Method and Description |
|---|---|
boolean |
checkGlobalFlag(String flagName)
Check the condition of a specified flag.
|
boolean |
checkServiceActive(String serviceType,
String serviceName)
Check whether a service is active or not.
|
boolean |
cleanupInactiveService(String serviceType,
IServiceCleanup cleanup)
Clean up any inactive services found.
|
void |
clearGlobalFlag(String flagName)
Clear a flag.
|
void |
clearLocks()
Clear all outstanding locks in the system.
|
int |
countActiveServices(String serviceType)
Count all active services of a given type.
|
void |
endServiceActivity(String serviceType,
String serviceName)
End service activity.
|
void |
enterCriticalSections(String[] readSectionKeys,
String[] nonExSectionKeys,
String[] writeSectionKeys)
Enter multiple critical sections simultaneously.
|
void |
enterLocks(String[] readLocks,
String[] nonExWriteLocks,
String[] writeLocks)
Enter multiple locks
|
void |
enterLocksNoWait(String[] readLocks,
String[] nonExWriteLocks,
String[] writeLocks)
Enter multiple locks simultaneously.
|
void |
enterNonExWriteCriticalSection(String sectionKey)
Enter a named, non-exclusive write critical section (NOT a lock).
|
void |
enterNonExWriteLock(String lockKey)
Enter a non-exclusive write-locked area (blocking out all readers, but letting in other "writers").
|
void |
enterNonExWriteLockNoWait(String lockKey)
Enter a non-exclusive write-locked area (blocking out all readers, but letting in other "writers").
|
void |
enterReadCriticalSection(String sectionKey)
Enter a named, read critical section (NOT a lock).
|
void |
enterReadLock(String lockKey)
Enter a read-only locked area (i.e., block ONLY if there's a writer)
|
void |
enterReadLockNoWait(String lockKey)
Enter a read-only locked area (i.e., block ONLY if there's a writer).
|
void |
enterWriteCriticalSection(String sectionKey)
Enter a named, exclusive critical section (NOT a lock).
|
void |
enterWriteLock(String lockKey)
Enter a write locked area (i.e., block out both readers and other writers)
NOTE: Can't enter until all readers have left.
|
void |
enterWriteLockNoWait(String lockKey)
Enter a write locked code area (i.e., block out both readers and other writers),
but do not wait if the lock cannot be obtained.
|
ManifoldCFConfiguration |
getSharedConfiguration()
Get the current shared configuration.
|
void |
leaveCriticalSections(String[] readSectionKeys,
String[] nonExSectionKeys,
String[] writeSectionKeys)
Leave multiple critical sections simultaneously.
|
void |
leaveLocks(String[] readLocks,
String[] writeNonExLocks,
String[] writeLocks)
Leave multiple locks
|
void |
leaveNonExWriteCriticalSection(String sectionKey)
Leave a named, non-exclusive write critical section (NOT a lock).
|
void |
leaveNonExWriteLock(String lockKey)
Leave a non-exclusive write lock.
|
void |
leaveReadCriticalSection(String sectionKey)
Leave a named, read critical section (NOT a lock).
|
void |
leaveReadLock(String lockKey)
Leave a read-locked code area.
|
void |
leaveWriteCriticalSection(String sectionKey)
Leave a named, exclusive critical section (NOT a lock).
|
void |
leaveWriteLock(String lockKey)
Leave a write locked code area.
|
byte[] |
readData(String resourceName)
Read data from a shared data resource.
|
String |
registerServiceBeginServiceActivity(String serviceType,
String serviceName,
byte[] initialData,
IServiceCleanup cleanup)
Register a service and begin service activity.
|
String |
registerServiceBeginServiceActivity(String serviceType,
String serviceName,
IServiceCleanup cleanup)
Register a service and begin service activity.
|
byte[] |
retrieveServiceData(String serviceType,
String serviceName)
Retrieve service data for a service.
|
void |
scanServiceData(String serviceType,
IServiceDataAcceptor dataAcceptor)
Scan service data for a service type.
|
void |
setGlobalFlag(String flagName)
Raise a flag.
|
void |
timedWait(int time)
Wait for a time before retrying a lock.
|
void |
updateServiceData(String serviceType,
String serviceName,
byte[] serviceData)
Set service data for a service.
|
void |
writeData(String resourceName,
byte[] data)
Write data to a shared data resource.
|
public static final String _rcsid
protected final ILockManager lockManager
public LockManager()
throws ManifoldCFException
ManifoldCFExceptionpublic String registerServiceBeginServiceActivity(String serviceType, String serviceName, IServiceCleanup cleanup) throws ManifoldCFException
registerServiceBeginServiceActivity in interface ILockManagerserviceType - is the type of service.serviceName - is the name of the service to register. If null is passed, a transient unique service name will be
created, and will be returned to the caller.cleanup - is called to clean up either the current service, or all services of this type, if no other active service exists.
May be null. Local service cleanup is never called if the serviceName argument is null.ManifoldCFExceptionpublic String registerServiceBeginServiceActivity(String serviceType, String serviceName, byte[] initialData, IServiceCleanup cleanup) throws ManifoldCFException
registerServiceBeginServiceActivity in interface ILockManagerserviceType - is the type of service.serviceName - is the name of the service to register. If null is passed, a transient unique service name will be
created, and will be returned to the caller.initialData - is the initial service data for this service.cleanup - is called to clean up either the current service, or all services of this type, if no other active service exists.
May be null. Local service cleanup is never called if the serviceName argument is null.ManifoldCFExceptionpublic void updateServiceData(String serviceType, String serviceName, byte[] serviceData) throws ManifoldCFException
updateServiceData in interface ILockManagerserviceType - is the type of service.serviceName - is the name of the service.serviceData - is the data to update to (may be null).
This updates the service's transient data (or deletes it). If the service is not active, an exception is thrown.ManifoldCFExceptionpublic byte[] retrieveServiceData(String serviceType, String serviceName) throws ManifoldCFException
retrieveServiceData in interface ILockManagerserviceType - is the type of service.serviceName - is the name of the service.ManifoldCFExceptionpublic void scanServiceData(String serviceType, IServiceDataAcceptor dataAcceptor) throws ManifoldCFException
scanServiceData in interface ILockManagerserviceType - is the type of service.dataAcceptor - is the object that will be notified of each item of data for each service name found.ManifoldCFExceptionpublic boolean cleanupInactiveService(String serviceType, IServiceCleanup cleanup) throws ManifoldCFException
cleanupInactiveService in interface ILockManagerserviceType - is the service type.cleanup - is the object to call to clean up an inactive service.ManifoldCFExceptionpublic int countActiveServices(String serviceType) throws ManifoldCFException
countActiveServices in interface ILockManagerserviceType - is the service type.ManifoldCFExceptionpublic void endServiceActivity(String serviceType, String serviceName) throws ManifoldCFException
endServiceActivity in interface ILockManagerserviceType - is the type of service.serviceName - is the name of the service to exit.ManifoldCFExceptionpublic boolean checkServiceActive(String serviceType, String serviceName) throws ManifoldCFException
checkServiceActive in interface ILockManagerserviceType - is the type of service.serviceName - is the name of the service to check on.ManifoldCFExceptionpublic ManifoldCFConfiguration getSharedConfiguration() throws ManifoldCFException
getSharedConfiguration in interface ILockManagerconfigurationData - is the globally-shared configuration information.ManifoldCFExceptionpublic void setGlobalFlag(String flagName) throws ManifoldCFException
setGlobalFlag in interface ILockManagerflagName - is the name of the flag to set.ManifoldCFExceptionpublic void clearGlobalFlag(String flagName) throws ManifoldCFException
clearGlobalFlag in interface ILockManagerflagName - is the name of the flag to clear.ManifoldCFExceptionpublic boolean checkGlobalFlag(String flagName) throws ManifoldCFException
checkGlobalFlag in interface ILockManagerflagName - is the name of the flag to check.ManifoldCFExceptionpublic byte[] readData(String resourceName) throws ManifoldCFException
readData in interface ILockManagerresourceName - is the global name of the resource.ManifoldCFExceptionpublic void writeData(String resourceName, byte[] data) throws ManifoldCFException
writeData in interface ILockManagerresourceName - is the global name of the resource.data - is the byte array containing the data. Pass null if you want to delete the resource completely.ManifoldCFExceptionpublic void timedWait(int time)
throws ManifoldCFException
timedWait in interface ILockManagertime - is the amount of time to wait, in milliseconds. Zero is a legal
value, and will wait no time, but will give up the current timeslice to another
thread.ManifoldCFExceptionpublic void enterNonExWriteLock(String lockKey) throws ManifoldCFException
enterNonExWriteLock in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionpublic void enterNonExWriteLockNoWait(String lockKey) throws ManifoldCFException, LockException
ILockManagerenterNonExWriteLockNoWait in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionLockExceptionpublic void leaveNonExWriteLock(String lockKey) throws ManifoldCFException
leaveNonExWriteLock in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionpublic void enterWriteLock(String lockKey) throws ManifoldCFException
enterWriteLock in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionpublic void enterWriteLockNoWait(String lockKey) throws ManifoldCFException, LockException
ILockManagerenterWriteLockNoWait in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionLockExceptionpublic void leaveWriteLock(String lockKey) throws ManifoldCFException
ILockManagerleaveWriteLock in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionpublic void enterReadLock(String lockKey) throws ManifoldCFException
enterReadLock in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionpublic void enterReadLockNoWait(String lockKey) throws ManifoldCFException, LockException
ILockManagerenterReadLockNoWait in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionLockExceptionpublic void leaveReadLock(String lockKey) throws ManifoldCFException
ILockManagerleaveReadLock in interface ILockManagerlockKey - is the name of the lock.ManifoldCFExceptionpublic void clearLocks()
throws ManifoldCFException
ILockManagerclearLocks in interface ILockManagerManifoldCFExceptionpublic void enterLocks(String[] readLocks, String[] nonExWriteLocks, String[] writeLocks) throws ManifoldCFException
enterLocks in interface ILockManagerreadLocks - is an array of read lock names, or null if there are no read locks desired.nonExWriteLocks - is an array of non-ex write lock names, or null if none desired.writeLocks - is an array of write lock names, or null if there are none desired.ManifoldCFExceptionpublic void enterLocksNoWait(String[] readLocks, String[] nonExWriteLocks, String[] writeLocks) throws ManifoldCFException, LockException
ILockManagerenterLocksNoWait in interface ILockManagerreadLocks - is an array of read lock names, or null if there are no read locks desired.nonExWriteLocks - is an array of non-ex write lock names, or null if none desired.writeLocks - is an array of write lock names, or null if there are none desired.ManifoldCFExceptionLockExceptionpublic void leaveLocks(String[] readLocks, String[] writeNonExLocks, String[] writeLocks) throws ManifoldCFException
leaveLocks in interface ILockManagerreadLocks - is an array of read lock names, or null if there are no read locks desired.writeNonExLocks - is an array of non-ex write lock names, or null if none desired.writeLocks - is an array of write lock names, or null if there are none desired.ManifoldCFExceptionpublic void enterReadCriticalSection(String sectionKey) throws ManifoldCFException
enterReadCriticalSection in interface ILockManagersectionKey - is the name of the section to enter. Only one thread can be in any given named
section at a time.ManifoldCFExceptionpublic void leaveReadCriticalSection(String sectionKey) throws ManifoldCFException
leaveReadCriticalSection in interface ILockManagersectionKey - is the name of the section to leave. Only one thread can be in any given named
section at a time.ManifoldCFExceptionpublic void enterNonExWriteCriticalSection(String sectionKey) throws ManifoldCFException
enterNonExWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to enter. Only one thread can be in any given named
section at a time.ManifoldCFExceptionpublic void leaveNonExWriteCriticalSection(String sectionKey) throws ManifoldCFException
leaveNonExWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to leave. Only one thread can be in any given named
section at a time.ManifoldCFExceptionpublic void enterWriteCriticalSection(String sectionKey) throws ManifoldCFException
enterWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to enter. Only one thread can be in any given named
section at a time.ManifoldCFExceptionpublic void leaveWriteCriticalSection(String sectionKey) throws ManifoldCFException
leaveWriteCriticalSection in interface ILockManagersectionKey - is the name of the section to leave. Only one thread can be in any given named
section at a time.ManifoldCFExceptionpublic void enterCriticalSections(String[] readSectionKeys, String[] nonExSectionKeys, String[] writeSectionKeys) throws ManifoldCFException
enterCriticalSections in interface ILockManagerreadSectionKeys - is an array of read section descriptors, or null if there are no read sections desired.nonExSectionKeys - is an array of non-ex write section descriptors, or null if none desired.writeSectionKeys - is an array of write section descriptors, or null if there are none desired.ManifoldCFExceptionpublic void leaveCriticalSections(String[] readSectionKeys, String[] nonExSectionKeys, String[] writeSectionKeys) throws ManifoldCFException
leaveCriticalSections in interface ILockManagerreadSectionKeys - is an array of read section descriptors, or null if there are no read sections desired.nonExSectionKeys - is an array of non-ex write section descriptors, or null if none desired.writeSectionKeys - is an array of write section descriptors, or null if there are none desired.ManifoldCFException