Class EConfigure.Dispatcher
- java.lang.Object
-
- net.sf.eBus.config.EConfigure.Dispatcher
-
- All Implemented Interfaces:
Comparable<EConfigure.Dispatcher>
- Enclosing class:
- EConfigure
public static final class EConfigure.Dispatcher extends Object implements Comparable<EConfigure.Dispatcher>
An application may create dispatch threads with a given unique name and JSON properties listed below.
Dispatcher JSON Properties Property Required? Type Default Description runQueueTypeNo ThreadTypeEConfigure.DEFAULT_THREAD_TYPEDispatcher thread is implemented as this type. priorityNo int≥Thread.MIN_PRIORITYand ≤Thread.MAX_PRIORITY.EConfigure.DEFAULT_PRIORITYThread scheduling priority. Must be quantumNo intEConfigure.DEFAULT_QUANTUMTask run-time quantum. Does not pre-empt tasks which exceed this time limit. numberThreadsNo int> zeroEConfigure.DEFAULT_NUMBER_THREADSDispatcher contains this many threads. isDefaultNo booleanfalseIf truemarks this as the default dispatcher. Only one dispatcher may be marked as the default.classesYes if isDefaultisfalseArray of Classnames. May not be empty. Class names must be accessible to this JVM instance.NA Dispatcher handles instances of these classes. threadAffinitiesNo Array of ThreadAffinityConfigureEmpty list Optional OpenHFT thread affinity configurations. Example dispatcher configuration.
name : d1 runQueueType : "spin+park" spinLimit : 2500000 parkTime : 500ns isDefault : true priority : 5 quantum : 10000ns numberThreads : 4Special Dispatchers
There are two special, pre-defined eBusDispatchernames:"swing"and"javafx"(case insensitive). TheseDispatchers use the Swing/JavaFX GUI thread to deliver eBus messages to a client. This means that the client callback is free to update the GUI because the callback code is running on the GUI thread.Only two properties are supported by special
Dispatchers:EConfigure.DEFAULT_KEYandEConfigure.CLASSES_KEY. All other properties are ignored by specialDispatchers. The reason is that the underlying GUI threads are implemented and configured by the GUI package and cannot be altered by eBus.It may be useful to define the GUI thread Dispatcher as the default Dispatcher and then create a separate eBus
Dispatcherfor non-GUI classes. This way, an application class updating the display will be assigned to the GUI thread without needing to add that class to the GUI Dispatcher classes property.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ThreadAffinityConfigure[]affinity()Returns thread affinity andnullif no affinity is set.Class<?>[]classes()Returns the classes assigned to this dispatcher.intcompareTo(EConfigure.Dispatcher o)EConfigure.DispatcherTypedispatchType()Returns the dispatch method type.booleanequals(Object o)inthashCode()booleanisDefault()Returnstrueif this user-defined dispatcher is the default dispatcher.Stringname()Returns the unique dispatcher name.intnumberThreads()Returns the number of threads in this dispatcher.DurationparkTime()Returns the park time used byspin+parkthread type.intpriority()Returns the dispatcher thread priority.Durationquantum()Returns the client run-time quantum assigned by this dispatcher.ThreadTyperunQueueType()Returns the thread type which defines how the next client is acquired from the run queue.longspinLimit()Returns the spin limit used byspin+parkandspin+yieldthread types.StringtoString()
-
-
-
Method Detail
-
compareTo
public int compareTo(EConfigure.Dispatcher o)
- Specified by:
compareToin interfaceComparable<EConfigure.Dispatcher>
-
name
public String name()
Returns the unique dispatcher name.- Returns:
- dispatcher thread name.
-
dispatchType
public EConfigure.DispatcherType dispatchType()
Returns the dispatch method type.- Returns:
- dispatch method type.
-
runQueueType
public ThreadType runQueueType()
Returns the thread type which defines how the next client is acquired from the run queue.- Returns:
- run queue-acquisition type.
-
spinLimit
public long spinLimit()
Returns the spin limit used byspin+parkandspin+yieldthread types.- Returns:
- spin limit.
-
parkTime
public Duration parkTime()
Returns the park time used byspin+parkthread type.- Returns:
- nanosecond park time.
-
isDefault
public boolean isDefault()
Returnstrueif this user-defined dispatcher is the default dispatcher.- Returns:
trueif the default dispatcher.
-
classes
public Class<?>[] classes()
Returns the classes assigned to this dispatcher. Returned array may be empty but will not benull.- Returns:
- dispatcher class array.
-
priority
public int priority()
Returns the dispatcher thread priority.- Returns:
- thread priority.
-
quantum
public Duration quantum()
Returns the client run-time quantum assigned by this dispatcher.- Returns:
- client run-time quantum.
-
numberThreads
public int numberThreads()
Returns the number of threads in this dispatcher.- Returns:
- dispatcher thread count.
-
affinity
public ThreadAffinityConfigure[] affinity()
Returns thread affinity andnullif no affinity is set. This affinity is used to associate a thread with a particular CPU.- Returns:
- thread affinity.
-
-