new thread pooling strategy and test program WIP

This commit is contained in:
Minjae Song
2018-12-14 22:53:25 +09:00
parent 6f49dcff4b
commit 513c5a17eb
8 changed files with 231 additions and 32 deletions

View File

@@ -204,7 +204,7 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
fun insertionSortLastElem(arr: ArrayList<Actor>) {
lock(ReentrantLock()) {
ReentrantLock().lock {
var j = arr.lastIndex - 1
val x = arr.last()
while (j >= 0 && arr[j] > x) {
@@ -215,13 +215,14 @@ open class IngameInstance(val batch: SpriteBatch) : Screen {
}
}
inline fun lock(lock: Lock, body: () -> Unit) {
lock.lock()
try {
body()
}
finally {
lock.unlock()
}
}
inline fun Lock.lock(body: () -> Unit) {
this.lock()
try {
body()
}
}
finally {
this.unlock()
}
}