mirror of
https://github.com/ethauvin/kobalt.git
synced 2025-04-27 00:38:11 -07:00
public
This commit is contained in:
parent
765fe5310f
commit
a4f3f93fc1
1 changed files with 5 additions and 6 deletions
|
@ -5,11 +5,10 @@ import java.util.concurrent.*
|
||||||
class NamedThreadFactory(val n: String) : ThreadFactory {
|
class NamedThreadFactory(val n: String) : ThreadFactory {
|
||||||
private val PREFIX = "K-"
|
private val PREFIX = "K-"
|
||||||
|
|
||||||
public val name: String
|
val name: String
|
||||||
get() = PREFIX + n
|
get() = PREFIX + n
|
||||||
|
|
||||||
override
|
override fun newThread(r: Runnable) : Thread {
|
||||||
public fun newThread(r: Runnable) : Thread {
|
|
||||||
val result = Thread(r)
|
val result = Thread(r)
|
||||||
result.name = name + "-" + result.id
|
result.name = name + "-" + result.id
|
||||||
return result
|
return result
|
||||||
|
@ -20,7 +19,7 @@ class KobaltExecutor(name: String, threadCount: Int)
|
||||||
: ThreadPoolExecutor(threadCount, threadCount, 5L, TimeUnit.SECONDS,
|
: ThreadPoolExecutor(threadCount, threadCount, 5L, TimeUnit.SECONDS,
|
||||||
LinkedBlockingQueue<Runnable>(), NamedThreadFactory(name)) {
|
LinkedBlockingQueue<Runnable>(), NamedThreadFactory(name)) {
|
||||||
|
|
||||||
override protected fun afterExecute(r: Runnable, t: Throwable?) {
|
override fun afterExecute(r: Runnable, t: Throwable?) {
|
||||||
super.afterExecute(r, t)
|
super.afterExecute(r, t)
|
||||||
var ex : Throwable? = null
|
var ex : Throwable? = null
|
||||||
if (t == null && r is Future<*>) {
|
if (t == null && r is Future<*>) {
|
||||||
|
@ -40,8 +39,8 @@ class KobaltExecutor(name: String, threadCount: Int)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class KobaltExecutors {
|
class KobaltExecutors {
|
||||||
public fun newExecutor(name: String, threadCount: Int) : ExecutorService
|
fun newExecutor(name: String, threadCount: Int) : ExecutorService
|
||||||
= KobaltExecutor(name, threadCount)
|
= KobaltExecutor(name, threadCount)
|
||||||
|
|
||||||
val dependencyExecutor = newExecutor("Dependency", 5)
|
val dependencyExecutor = newExecutor("Dependency", 5)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue