blob: c4dbcebf9cbeb46d6a2c670fa611e17c01a0d1fe (
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
|
// Copyright 2017 Yahoo Holdings. 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);
}
}
|