diff options
Diffstat (limited to 'vespajlib/src/main/java/com/yahoo/concurrent/lock/Lock.java')
-rw-r--r-- | vespajlib/src/main/java/com/yahoo/concurrent/lock/Lock.java | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/vespajlib/src/main/java/com/yahoo/concurrent/lock/Lock.java b/vespajlib/src/main/java/com/yahoo/concurrent/lock/Lock.java new file mode 100644 index 00000000000..1273a298592 --- /dev/null +++ b/vespajlib/src/main/java/com/yahoo/concurrent/lock/Lock.java @@ -0,0 +1,24 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.concurrent.lock; + +import java.util.concurrent.locks.ReentrantLock; + +/** + * An acquired lock which is released on close + * + * @author bratseth + */ +public final class Lock implements AutoCloseable { + + private final ReentrantLock wrappedLock; + + Lock(ReentrantLock wrappedLock) { + this.wrappedLock = wrappedLock; + } + + /** Releases this lock */ + public void close() { + wrappedLock.unlock(); + } + +} |