Package edu.tufts.hrilab.action.lock
Class ActionResourceLock
java.lang.Object
edu.tufts.hrilab.action.lock.ActionResourceLock
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ActionResourceLockLinear
,ActionResourceLockPreempt
ActionResourceLock
is the base class for Action's resource
locks.- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic ActionResourceLock
static ActionResourceLock
static ActionResourceLock
static ActionResourceLock
static ActionResourceLock
static ActionResourceLock
static ActionResourceLock
static ActionResourceLock
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract boolean
acquire
(ActionInterpreter actionInt, int count) Must be implemented by subclass.boolean
blockingAcquire
(ActionInterpreter actionInt) Acquire the resource lock, waiting indefinitely for it to become available.void
deepRelease
(ActionInterpreter actionInt) Release the resource lock, ensuring that the current AI is the current holder.static void
static ActionResourceLock
Get a resource lock.getOwner()
Get the interpreter currently holding the lock.boolean
nonBlockingAcquire
(ActionInterpreter actionInt) Attempt to acquire the resource lock, but do not block if it is unavailable.void
release
(ActionInterpreter actionInt) Release the resource lock, ensuring that the current AI is the current holder.toString()
-
Field Details
-
lockName
-
owner
-
faceLock
-
blinkLock
-
headLock
-
motionLock
-
transmitLock
-
visionLock
-
speechLock
-
lightLock
-
-
Constructor Details
-
ActionResourceLock
Constructor for a resource lock.- Parameters:
name
- the lock's name
-
-
Method Details
-
getLock
Get a resource lock.- Parameters:
lockName
- the name of the lock to get- Returns:
- the lock
-
acquire
Must be implemented by subclass. -
getLockName
-
blockingAcquire
Acquire the resource lock, waiting indefinitely for it to become available.- Parameters:
actionInt
- the ActionInterpreter requesting the lock- Returns:
- true if the lock is acquired
-
nonBlockingAcquire
Attempt to acquire the resource lock, but do not block if it is unavailable.- Parameters:
actionInt
- the ActionInterpreter requesting the lock- Returns:
- true if the lock is acquired, false otherwise
-
release
Release the resource lock, ensuring that the current AI is the current holder. This version releases only one level of recursive acquire; if an enclosing script also acquired the lock, actionInt will still hold it.- Parameters:
actionInt
- the ActionInterpreter releasing the lock
-
deepRelease
Release the resource lock, ensuring that the current AI is the current holder. This version ensures the lock will be released, regardless of how many recursive acquires the owner has made.- Parameters:
actionInt
- the ActionInterpreter releasing the lock
-
getOwner
Get the interpreter currently holding the lock.- Returns:
- the owner
-
toString
-
deepReleaseAll
-