LockPerf benchmark

This commit is contained in:
Alex Tkachman
2011-12-19 15:57:48 +02:00
parent 2ae3e9e6c6
commit e19acf4922
+3 -12
View File
@@ -1,20 +1,11 @@
namespace lockperformance
import std.concurrent.*
import java.util.concurrent.atomic.AtomicInteger;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.locks.ReentrantLock;
fun thread(f: fun ()) {
val thread = Thread(
object: Runnable {
override fun run() {
f()
}
}
)
thread.start()
}
fun <T> Int.latch(op: fun CountDownLatch.() : T) : T {
val cdl = CountDownLatch(this)
val res = cdl.op()
@@ -22,7 +13,7 @@ fun <T> Int.latch(op: fun CountDownLatch.() : T) : T {
return res
}
fun Int.times(action: fun Int.()) {
fun Int.times(action: fun():Unit) {
for(i in 0..this-1)
action()
}