Package one.microstream.functional
Interface ParallelProcedure.LogicProvider<S,P extends Consumer<? super S>>
- All Known Implementing Classes:
ParallelProcedure.LogicProvider.SingletonLogic
- Enclosing interface:
- ParallelProcedure<E>
public static interface ParallelProcedure.LogicProvider<S,P extends Consumer<? super S>>
Type providing the actual logic
Consumer
to be applied to the elements enountered by a
ParallelProcedure
. Providing can mean anything from creating a new lightweight instance on each call
of provideLogic()
to lazy creation caching or pooling heavyweight instances.-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static class
ParallelProcedure.LogicProvider.SingletonLogic<S,P extends Consumer<? super S>>
-
Method Summary
Modifier and Type Method Description void
disposeLogic(P logic, Throwable cause)
Signals the provider instance that the passed logic instance is no longer used and provides the cause for its disposal (e.g.P
provideLogic()
Provides the actual logicConsumer
to be applied to the elements enountered by aParallelProcedure
.
-
Method Details
-
provideLogic
P provideLogic()Provides the actual logicConsumer
to be applied to the elements enountered by aParallelProcedure
.This method always gets called by the actual worker thread that will use the provided logic, so that a call of
Thread.currentThread()
inside the method will always return the logic executing thread. The intention is to give complex provider implementations a chance to get to know the executing thread before the logic is executed. It is however stronly discouraged to try and control the worker thread activity from outside as it can disturb or disrupt the actual thread management. E.g. any explicit interruption can cause the worker thread to be abolished and killed and the logic instance to be disposed.- Returns:
- the logic instance to be used by a worker thread.
-
disposeLogic
Signals the provider instance that the passed logic instance is no longer used and provides the cause for its disposal (e.g. anInterruptedException
because the executing worker has been abolished)An implementation of this method can be anything from a no-op to complex resource clean up.
- Parameters:
logic
- the not longer used logic that shall be disposed.cause
- the cause for the disposal.
-