1 package locklib;
2
3
4
5 /**
6 * A wait queue manages lock requests that are pending for a target,
7 * deciding in which order should the locks be obtained.
8 * @param <LockType> the type of locks
9 */
10 public abstract class WaitQueue<LockType>
11 implements Iterable<LockGrantFuture<LockType>> {
12 /**
13 * Creates a new queue.
14 */
15 public WaitQueue() {
16 }
17
18 /**
19 * Adds a new request to the queue.
20 * @param r the request
21 */
22 protected abstract void enqueue(LockGrantFuture<LockType> r);
23
24 /**
25 * Removes a request from the queue.
26 * @param r the request; if the request is not queued, then nothing
27 * happens
28 */
29 protected abstract void dequeue(LockGrantFuture<LockType> r);
30 }