blob: d05cb14c64ff12150357b83f3989e74b380d4dbd (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.concurrent.classlock;
/**
* An acquired lock which is released on close
*
* @author valerijf
*/
public class ClassLock implements AutoCloseable {
private final Class<?> clazz;
private final ClassLocking classLocking;
ClassLock(ClassLocking classLocking, Class<?> clazz) {
this.classLocking = classLocking;
this.clazz = clazz;
}
/**
* Releases this lock
*
* @throws IllegalArgumentException if this lock has already been released
*/
@Override
public void close() {
classLocking.unlock(clazz, this);
}
}
|