Class 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
    runQueueType No ThreadType EConfigure.DEFAULT_THREAD_TYPE Dispatcher thread is implemented as this type.
    priority No intThread.MIN_PRIORITY and ≤ Thread.MAX_PRIORITY. EConfigure.DEFAULT_PRIORITY Thread scheduling priority. Must be
    quantum No int EConfigure.DEFAULT_QUANTUM Task run-time quantum. Does not pre-empt tasks which exceed this time limit.
    numberThreads No int > zero EConfigure.DEFAULT_NUMBER_THREADS Dispatcher contains this many threads.
    isDefault No boolean false If true marks this as the default dispatcher. Only one dispatcher may be marked as the default.
    classes Yes if isDefault is false Array of Class names. May not be empty. Class names must be accessible to this JVM instance. NA Dispatcher handles instances of these classes.
    threadAffinities No Array of ThreadAffinityConfigure Empty 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 : 4

    Special Dispatchers

    There are two special, pre-defined eBus Dispatcher names: "swing" and "javafx" (case insensitive). These Dispatchers 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_KEY and EConfigure.CLASSES_KEY. All other properties are ignored by special Dispatchers. 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 Dispatcher for 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 Detail

      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object
      • 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 by spin+park and spin+yield thread types.
        Returns:
        spin limit.
      • parkTime

        public Duration parkTime()
        Returns the park time used by spin+park thread type.
        Returns:
        nanosecond park time.
      • isDefault

        public boolean isDefault()
        Returns true if this user-defined dispatcher is the default dispatcher.
        Returns:
        true if the default dispatcher.
      • classes

        public Class<?>[] classes()
        Returns the classes assigned to this dispatcher. Returned array may be empty but will not be null.
        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 and null if no affinity is set. This affinity is used to associate a thread with a particular CPU.
        Returns:
        thread affinity.