Class MCRProcessableFactory
java.lang.Object
org.mycore.util.concurrent.processing.MCRProcessableFactory
Factory and utility methods for
MCRProcessableExecutor
.- Author:
- Matthias Eichner
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic MCRProcessableExecutor
newPool
(ExecutorService delegate) Creates a newMCRProcessableExecutor
.static MCRProcessableExecutor
newPool
(ExecutorService delegate, MCRProcessableCollection collection) Creates a newMCRProcessableExecutor
.static PriorityBlockingQueue<Runnable>
Creates new PriorityBlockingQueue for runnables.progressableCallable
(Runnable task) Returns aCallable
object that, when called, runs the given task and returnsnull
.
-
Constructor Details
-
MCRProcessableFactory
public MCRProcessableFactory()
-
-
Method Details
-
progressableCallable
Returns aCallable
object that, when called, runs the given task and returnsnull
. It also takes care if the task implements theMCRProgressable
interface by calling the runnable implementation.- Parameters:
task
- the task to run- Returns:
- a callable object
- Throws:
NullPointerException
- if task null
-
newPool
Creates a newMCRProcessableExecutor
.Be aware that you should shutdown the delegate with the
MCRShutdownHandler
by yourself. This method will not do this for you!If you like to have priority support you have to use a thread pool with a
PriorityBlockingQueue
!- Parameters:
delegate
- the thread pool delegate- Returns:
- a newly created thread pool
-
newPool
public static MCRProcessableExecutor newPool(ExecutorService delegate, MCRProcessableCollection collection) Creates a newMCRProcessableExecutor
. Each task submitted will be automatically added to the given collection and removed if complete.Be aware that you should shutdown the delegate with the
MCRShutdownHandler
by yourself. This method will not do this for you!If you like to have priority support you have to use a thread pool with a
PriorityBlockingQueue
!- Parameters:
delegate
- the thread pool delegatecollection
- the collection which will be linked with the pool- Returns:
- a newly created thread pool
-
newPriorityBlockingQueue
Creates new PriorityBlockingQueue for runnables. Uses theMCRRunnableComperator
for comparision.- Returns:
- a new priority blocking queue
-