Don't provide executor by default
This commit is contained in:
parent
4972bea1ce
commit
021b991ab5
@ -6,12 +6,9 @@ import java.util.concurrent.ConcurrentLinkedQueue
|
|||||||
import java.util.concurrent.ExecutionException
|
import java.util.concurrent.ExecutionException
|
||||||
import java.util.concurrent.Executor
|
import java.util.concurrent.Executor
|
||||||
import java.util.concurrent.ExecutorService
|
import java.util.concurrent.ExecutorService
|
||||||
import java.util.concurrent.ForkJoinPool
|
|
||||||
import java.util.concurrent.Future
|
import java.util.concurrent.Future
|
||||||
import java.util.concurrent.FutureTask
|
import java.util.concurrent.FutureTask
|
||||||
import java.util.concurrent.RejectedExecutionException
|
import java.util.concurrent.RejectedExecutionException
|
||||||
import java.util.concurrent.SynchronousQueue
|
|
||||||
import java.util.concurrent.ThreadPoolExecutor
|
|
||||||
import java.util.concurrent.TimeUnit
|
import java.util.concurrent.TimeUnit
|
||||||
import java.util.concurrent.atomic.AtomicBoolean
|
import java.util.concurrent.atomic.AtomicBoolean
|
||||||
import java.util.concurrent.locks.LockSupport
|
import java.util.concurrent.locks.LockSupport
|
||||||
@ -23,8 +20,6 @@ import java.util.concurrent.locks.LockSupport
|
|||||||
* [CarriedExecutor], since when they are done, they unmount themselves from [parentExecutor], allowing thread to perform other work
|
* [CarriedExecutor], since when they are done, they unmount themselves from [parentExecutor], allowing thread to perform other work
|
||||||
*/
|
*/
|
||||||
class CarriedExecutor(private val parentExecutor: Executor) : Runnable, ExecutorService {
|
class CarriedExecutor(private val parentExecutor: Executor) : Runnable, ExecutorService {
|
||||||
constructor() : this(ASYNC_POOL)
|
|
||||||
|
|
||||||
private val isCarried = AtomicBoolean()
|
private val isCarried = AtomicBoolean()
|
||||||
private val queue = ConcurrentLinkedQueue<Runnable>()
|
private val queue = ConcurrentLinkedQueue<Runnable>()
|
||||||
private val isShutdown = AtomicBoolean()
|
private val isShutdown = AtomicBoolean()
|
||||||
@ -189,13 +184,4 @@ class CarriedExecutor(private val parentExecutor: Executor) : Runnable, Executor
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
|
||||||
/**
|
|
||||||
* Default executor -- ForkJoinPool.commonPool() unless it cannot
|
|
||||||
* support parallelism.
|
|
||||||
*/
|
|
||||||
private val ASYNC_POOL: Executor =
|
|
||||||
if (ForkJoinPool.getCommonPoolParallelism() > 1) ForkJoinPool.commonPool() else ThreadPoolExecutor(0, Int.MAX_VALUE, 10L, TimeUnit.SECONDS, SynchronousQueue())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user