Merged in fix-affinityexecutor-test (pull request #117)

Attempt to fix AffinityExecutorTest and fix an IDE hint.
This commit is contained in:
Mike Hearn 2016-05-31 15:56:10 +02:00
commit 1e0844ccb5
2 changed files with 4 additions and 2 deletions

View File

@ -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 {

View File

@ -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)