splitted up akka-core into three modules; akka-actors, akka-typed-actors, akka-core

This commit is contained in:
Jonas Bonér 2010-08-24 23:21:28 +02:00
parent b7b79484ba
commit c67b17a912
149 changed files with 11195 additions and 1399 deletions

View file

@ -1,60 +0,0 @@
/**
* Copyright (C) 2009-2010 Scalable Solutions AB <http://scalablesolutions.se>
*/
package se.scalablesolutions.akka.util
import java.util.concurrent.locks.{ReentrantReadWriteLock, ReentrantLock}
/**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
class ReentrantGuard {
val lock = new ReentrantLock
def withGuard[T](body: => T): T = {
lock.lock
try {
body
} finally {
lock.unlock
}
}
def tryWithGuard[T](body: => T): T = {
while(!lock.tryLock) { Thread.sleep(10) } // wait on the monitor to be unlocked
try {
body
} finally {
lock.unlock
}
}
}
/**
* @author <a href="http://jonasboner.com">Jonas Bon&#233;r</a>
*/
class ReadWriteGuard {
private val rwl = new ReentrantReadWriteLock
private val readLock = rwl.readLock
private val writeLock = rwl.writeLock
def withWriteGuard[T](body: => T): T = {
writeLock.lock
try {
body
} finally {
writeLock.unlock
}
}
def withReadGuard[T](body: => T): T = {
readLock.lock
try {
body
} finally {
readLock.unlock
}
}
}