mirror of
https://github.com/corda/corda.git
synced 2024-12-20 13:33:12 +00:00
Merged in fix-affinityexecutor-test (pull request #117)
Attempt to fix AffinityExecutorTest and fix an IDE hint.
This commit is contained in:
commit
1e0844ccb5
@ -53,7 +53,7 @@ interface AffinityExecutor : Executor {
|
||||
*/
|
||||
class ServiceAffinityExecutor(threadName: String, numThreads: Int) : AffinityExecutor,
|
||||
ThreadPoolExecutor(numThreads, numThreads, 0L, TimeUnit.MILLISECONDS, LinkedBlockingQueue<Runnable>()) {
|
||||
protected val threads = Collections.synchronizedSet(HashSet<Thread>())
|
||||
private val threads = Collections.synchronizedSet(HashSet<Thread>())
|
||||
private val uncaughtExceptionHandler = Thread.currentThread().uncaughtExceptionHandler
|
||||
|
||||
init {
|
||||
|
@ -59,18 +59,20 @@ class AffinityExecutorTests {
|
||||
assert(!executor.isOnThread)
|
||||
|
||||
val latch = CountDownLatch(1)
|
||||
val latch2 = CountDownLatch(2)
|
||||
val threads = Collections.synchronizedList(ArrayList<Thread>())
|
||||
|
||||
fun blockAThread() {
|
||||
executor.execute {
|
||||
assert(executor.isOnThread)
|
||||
threads += Thread.currentThread()
|
||||
latch2.countDown()
|
||||
latch.await()
|
||||
}
|
||||
}
|
||||
blockAThread()
|
||||
blockAThread()
|
||||
executor.flush()
|
||||
latch2.await()
|
||||
assertEquals(2, threads.size)
|
||||
val numThreads = executor.fetchFrom {
|
||||
assert(executor.isOnThread)
|
||||
|
Loading…
Reference in New Issue
Block a user