net.java.truevfs.kernel.impl.LockOn.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of truevfs-kernel-impl Show documentation
Show all versions of truevfs-kernel-impl Show documentation
Implements the API for accessing the federated virtual file system space.
This reference implementation can get overridden by providing another
file system manager factory implementation with a higher priority on
the class path.
/*
* Copyright (C) 2005-2012 Schlichtherle IT Services.
* All rights reserved. Use is subject to license terms.
*/
package net.java.truevfs.kernel.impl
import java.util.concurrent.locks._
/** Runs an operation while a lock is held.
*
* @author Christian Schlichtherle
*/
private object LockOn {
/** Runs the given `operation` while the given `lock` is held.
*
* @param lock the lock to acquire.
* @param operation the operation to run.
*/
def apply[V](lock: Lock)(operation: => V) = {
lock lock ()
try {
operation
} finally {
lock unlock ()
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy