net.java.truevfs.kernel.impl.ReadWriteLockAspect.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._
import javax.annotation.concurrent._
/** A mixin which provides some features of its associated read/write `lock`.
*
* @author Christian Schlichtherle
*/
@ThreadSafe
private trait ReadWriteLockAspect[+L <: ReadWriteLock] {
/** The read/write lock with the features to provide as an aspect. */
def lock: L
/** Returns the read lock. */
final def readLock = lock.readLock
/** Runs the given operation while the read lock is held. */
final def readLocked[V] = LockOn[V](readLock)_
/** Returns the write lock. */
final def writeLock = lock.writeLock
/** Runs the given operation while the write lock is held. */
final def writeLocked[V] = LockOn[V](writeLock)_
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy