public class TaskLockbox extends Object
Constructor and Description |
---|
TaskLockbox(TaskStorage taskStorage) |
Modifier and Type | Method and Description |
---|---|
List<TaskLock> |
findLocksForTask(Task task)
Return the currently-active locks for some task.
|
TaskLock |
lock(Task task,
org.joda.time.Interval interval)
Acquires a lock on behalf of a task.
|
void |
syncFromStorage()
Wipe out our current in-memory state and resync it from our bundled
TaskStorage . |
com.google.common.base.Optional<TaskLock> |
tryLock(Task task,
org.joda.time.Interval interval)
Attempt to lock a task, without removing it from the queue.
|
void |
unlock(Task task)
Release all locks for a task.
|
void |
unlock(Task task,
org.joda.time.Interval interval)
Release lock held for a task on a particular interval.
|
@Inject public TaskLockbox(TaskStorage taskStorage)
public void syncFromStorage()
TaskStorage
.public TaskLock lock(Task task, org.joda.time.Interval interval) throws InterruptedException
task
- task to acquire lock forinterval
- interval to lockInterruptedException
- if the lock cannot be acquiredpublic com.google.common.base.Optional<TaskLock> tryLock(Task task, org.joda.time.Interval interval)
tryLock
with no preferred version.task
- task that wants a lockinterval
- interval to lockpublic List<TaskLock> findLocksForTask(Task task)
task
- task for which to locate lockspublic void unlock(Task task, org.joda.time.Interval interval)
task
- task to unlockinterval
- interval to unlockpublic void unlock(Task task)
task
- task to unlockCopyright © 2011–2015. All rights reserved.