public abstract class BaseRedSynchronizer extends Object
RedSynchronizer
and RedVoidSynchronizer
.
The Synchronizers instances use a Synchronizer idiom to define the different
aspects of the execution.
Synchronizer idiom is separated into statements. Each statement constructs a single
execution which can either be resulted in a value, or void.
The phase of declaring an execution is called The Construction Chain.
The different stages of the Construction Chain are called middleware.
Each middleware is responsible for a different aspect of the resulted execution.
The different middleware are:
BaseRedSynchronizer.FutureTransformer
which receives and forwards the number of preconditions
of the execution, and responsible for manipulating the expectation from those preconditions.BaseRedSynchronizer.ReturnClassifier
which receives and forwards the number of preconditions and
the expectation from them, and responsible to set the method of returning values of the execution.BaseRedSynchronizer.Runner
which receives and forwards the number of preconditions, the
expectation from them and the method of returning values of the execution, and responsible
for invoking the BaseRedSynchronizer.Function
or BaseRedSynchronizer.Command
given to it.BaseRedSynchronizer.Function
or a BaseRedSynchronizer.Command
is invoked, the Construction Chain is completed,
and an tracking object is returned.
In case the execution returns a value, the tracking object will be a BaseRedSynchronizer.Result
,
in case the execution returns void, the tracking object will be a BaseRedSynchronizer.Marker
.
Both BaseRedSynchronizer.Result
and BaseRedSynchronizer.Marker
can be passed back as precondition to
another Construction Chain in any following statement of the Synchronizer idiom.Modifier and Type | Class and Description |
---|---|
protected static interface |
BaseRedSynchronizer.Command
A function to be invoked with expected number of parameters,
and a
BaseRedSynchronizer.PendingMarker to mark the completion of the execution |
protected static interface |
BaseRedSynchronizer.Function
A function to be invoked with expected number of parameters,
and return the result wrapper
|
protected static class |
BaseRedSynchronizer.FutureTransformer<RETURN_CLASSIFIER extends BaseRedSynchronizer.ReturnClassifier>
A middleware class to manipulate and transform future status.
|
protected static class |
BaseRedSynchronizer.Marker
Class Representing the void-result of an async execution, which can either
successfully complete, or fail with a
Throwable |
protected static class |
BaseRedSynchronizer.PendingMarker
Class representing a
BaseRedSynchronizer.Marker pending the execution completion,
and can be invoked to mark either success or failure completions |
protected static class |
BaseRedSynchronizer.Result<T>
Class representing the result of an async execution, when completed
producing either a value of T or a
Throwable |
protected static class |
BaseRedSynchronizer.Results
Class representing the results of N different preconditions
It can be used to retrieve values of index based precondition results
|
protected static class |
BaseRedSynchronizer.ReturnClassifier<COMMAND extends BaseRedSynchronizer.Command,TRANSFORMER extends BaseRedSynchronizer.FutureTransformer.Locked>
A middleware class to choose which kind of method the result of the calculation
is returned in.
|
protected static class |
BaseRedSynchronizer.Runner<FUNCTION extends BaseRedSynchronizer.Function,WRAPPER,R>
A middleware class to enable calling the actual function to execute.
|
Constructor and Description |
---|
BaseRedSynchronizer() |
Modifier and Type | Method and Description |
---|---|
protected BaseRedSynchronizer.Marker |
execute(BaseRedSynchronizer.Command.Command0 command)
Execute the given command directly, without waiting for any result or markers,
and return a marker of the execution.
|
protected BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked0 |
ifMarkers(BaseRedSynchronizer.Marker... markers)
Receive markers of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of results to expect, and then run a certain function if condition is met. |
protected <T0> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked1<T0> |
ifResult(BaseRedSynchronizer.Result<T0> f0)
Receive a result of an execution, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given result, and then run a certain function
if condition is met. |
protected BaseRedSynchronizer.FutureTransformer.Unlocked.UnlockedN |
ifResults(BaseRedSynchronizer.Result... results)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked2<T0,T1> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked3<T0,T1,T2> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3,T4> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3,
BaseRedSynchronizer.Result<T4> f4)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3,T4,T5> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3,
BaseRedSynchronizer.Result<T4> f4,
BaseRedSynchronizer.Result<T5> f5)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3,T4,T5,T6> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3,
BaseRedSynchronizer.Result<T4> f4,
BaseRedSynchronizer.Result<T5> f5,
BaseRedSynchronizer.Result<T6> f6)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3,T4,T5,T6,T7> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3,
BaseRedSynchronizer.Result<T4> f4,
BaseRedSynchronizer.Result<T5> f5,
BaseRedSynchronizer.Result<T6> f6,
BaseRedSynchronizer.Result<T7> f7)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3,T4,T5,T6,T7,T8> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3,
BaseRedSynchronizer.Result<T4> f4,
BaseRedSynchronizer.Result<T5> f5,
BaseRedSynchronizer.Result<T6> f6,
BaseRedSynchronizer.Result<T7> f7,
BaseRedSynchronizer.Result<T8> f8)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> |
ifResults(BaseRedSynchronizer.Result<T0> f0,
BaseRedSynchronizer.Result<T1> f1,
BaseRedSynchronizer.Result<T2> f2,
BaseRedSynchronizer.Result<T3> f3,
BaseRedSynchronizer.Result<T4> f4,
BaseRedSynchronizer.Result<T5> f5,
BaseRedSynchronizer.Result<T6> f6,
BaseRedSynchronizer.Result<T7> f7,
BaseRedSynchronizer.Result<T8> f8,
BaseRedSynchronizer.Result<T9> f9)
Receive a results of various executions, returns a
BaseRedSynchronizer.FutureTransformer to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met. |
protected <R> BaseRedSynchronizer.Runner.Runner0<R,R> |
produce(Class<R> tClass)
Produce value of the given class directly, without waiting for any result or markers,
and return a result of the execution
Since the are no preconditions and the return method is already defined at this point,
this call skips some middleware of the Construction Chain and goes directly to the
runner phase.
|
protected <R> BaseRedSynchronizer.Runner.Runner0<Future<R>,R> |
produceFutureOf(Class<R> tClass)
Produce
Future of the given class directly, without waiting for any result or markers,
and return a result of the execution
Since the are no preconditions and the return method is already defined at this point,
this call skips some middleware of the Construction Chain and goes directly to the
runner phase. |
protected BaseRedSynchronizer.Marker execute(BaseRedSynchronizer.Command.Command0 command)
command
- command to executeprotected <R> BaseRedSynchronizer.Runner.Runner0<R,R> produce(Class<R> tClass)
R
- type of the result to producetClass
- class of the result to produceprotected <R> BaseRedSynchronizer.Runner.Runner0<Future<R>,R> produceFutureOf(Class<R> tClass)
Future
of the given class directly, without waiting for any result or markers,
and return a result of the execution
Since the are no preconditions and the return method is already defined at this point,
this call skips some middleware of the Construction Chain and goes directly to the
runner phase.R
- type of the result to producetClass
- class of the result to produceprotected BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked0 ifMarkers(BaseRedSynchronizer.Marker... markers)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of results to expect, and then run a certain function if condition is met.
Initiates the Construction Chain with 0 parameters.markers
- markers to be used as preconditionsBaseRedSynchronizer.FutureTransformer
to choose which kind of results to expectprotected <T0> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked1<T0> ifResult(BaseRedSynchronizer.Result<T0> f0)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given result, and then run a certain function
if condition is met.
Initiates the Construction Chain with 1 parameter.T0
- type of result0f0
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultprotected <T0,T1> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked2<T0,T1> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 2 parameters.T0
- type of result0T1
- type of result1f0
- result to be used as preconditionf1
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked3<T0,T1,T2> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 3 parameters.T0
- type of result0T1
- type of result1T2
- type of result2f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked4<T0,T1,T2,T3> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 4 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3,T4> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked5<T0,T1,T2,T3,T4> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3, BaseRedSynchronizer.Result<T4> f4)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 5 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3T4
- type of result4f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionf4
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3,T4,T5> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked6<T0,T1,T2,T3,T4,T5> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3, BaseRedSynchronizer.Result<T4> f4, BaseRedSynchronizer.Result<T5> f5)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 6 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3T4
- type of result4T5
- type of result5f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionf4
- result to be used as preconditionf5
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3,T4,T5,T6> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked7<T0,T1,T2,T3,T4,T5,T6> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3, BaseRedSynchronizer.Result<T4> f4, BaseRedSynchronizer.Result<T5> f5, BaseRedSynchronizer.Result<T6> f6)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 7 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3T4
- type of result4T5
- type of result5T6
- type of result6f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionf4
- result to be used as preconditionf5
- result to be used as preconditionf6
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3,T4,T5,T6,T7> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked8<T0,T1,T2,T3,T4,T5,T6,T7> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3, BaseRedSynchronizer.Result<T4> f4, BaseRedSynchronizer.Result<T5> f5, BaseRedSynchronizer.Result<T6> f6, BaseRedSynchronizer.Result<T7> f7)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 8 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3T4
- type of result4T5
- type of result5T6
- type of result6T7
- type of result7f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionf4
- result to be used as preconditionf5
- result to be used as preconditionf6
- result to be used as preconditionf7
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3,T4,T5,T6,T7,T8> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked9<T0,T1,T2,T3,T4,T5,T6,T7,T8> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3, BaseRedSynchronizer.Result<T4> f4, BaseRedSynchronizer.Result<T5> f5, BaseRedSynchronizer.Result<T6> f6, BaseRedSynchronizer.Result<T7> f7, BaseRedSynchronizer.Result<T8> f8)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 9 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3T4
- type of result4T5
- type of result5T6
- type of result6T7
- type of result7T8
- type of result8f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionf4
- result to be used as preconditionf5
- result to be used as preconditionf6
- result to be used as preconditionf7
- result to be used as preconditionf8
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected <T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> BaseRedSynchronizer.FutureTransformer.Unlocked.Unlocked10<T0,T1,T2,T3,T4,T5,T6,T7,T8,T9> ifResults(BaseRedSynchronizer.Result<T0> f0, BaseRedSynchronizer.Result<T1> f1, BaseRedSynchronizer.Result<T2> f2, BaseRedSynchronizer.Result<T3> f3, BaseRedSynchronizer.Result<T4> f4, BaseRedSynchronizer.Result<T5> f5, BaseRedSynchronizer.Result<T6> f6, BaseRedSynchronizer.Result<T7> f7, BaseRedSynchronizer.Result<T8> f8, BaseRedSynchronizer.Result<T9> f9)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with 10 parameters.T0
- type of result0T1
- type of result1T2
- type of result2T3
- type of result3T4
- type of result4T5
- type of result5T6
- type of result6T7
- type of result7T8
- type of result8T9
- type of result9f0
- result to be used as preconditionf1
- result to be used as preconditionf2
- result to be used as preconditionf3
- result to be used as preconditionf4
- result to be used as preconditionf5
- result to be used as preconditionf6
- result to be used as preconditionf7
- result to be used as preconditionf8
- result to be used as preconditionf9
- result to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsprotected BaseRedSynchronizer.FutureTransformer.Unlocked.UnlockedN ifResults(BaseRedSynchronizer.Result... results)
BaseRedSynchronizer.FutureTransformer
to choose which
kind of completion to expect for given results, and then run a certain function
if condition is met.
Initiates the Construction Chain with N parameters.results
- results to be used as preconditionBaseRedSynchronizer.FutureTransformer
to choose which kind of completion to expect for given resultsCopyright © 2017. All rights reserved.