Package net.sf.eBus.config
Enum ThreadType
- java.lang.Object
-
- java.lang.Enum<ThreadType>
-
- net.sf.eBus.config.ThreadType
-
- All Implemented Interfaces:
Serializable,Comparable<ThreadType>
public enum ThreadType extends Enum<ThreadType>
Lists the thread types available to eBus users when configuring eBus. A dispatcher thread either:- blocks while waiting for the desire event to occur,
- spins, repeatedly check for the event to occur, or
-
spins a specified number of times on the event check and,
if the event does not occur when the spin limit is
reached, then
parksfor the nanosecond time. -
spins a specified number of times on the event check and,
if the event does not occur when the spin limit is
reached, then
parksfor an indefinite time.
- Author:
- Charles W. Rapp
-
-
Enum Constant Summary
Enum Constants Enum Constant Description BLOCKINGThe thread blocks while waiting for the desired event to occur.SPINNINGThe thread repeatedly checks if the event has arrived using a non-blocking call without pausing in between checks.SPINPARKThis thread repeatedly checks for the event using a non-blocking call but only for a fixed number of times (the spin limit).SPINYIELDThis thread repeatedly check for the event using a non-blocking call but only for a fixed number of times (the spin limit).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ThreadTypefind(String s)Returns the thread type with a text name equalings, ignoring case.StringtextName()Returns the thread type text name.StringtoString()static ThreadTypevalueOf(String name)Returns the enum constant of this type with the specified name.static ThreadType[]values()Returns an array containing the constants of this enum type, in the order they are declared.
-
-
-
Enum Constant Detail
-
BLOCKING
public static final ThreadType BLOCKING
The thread blocks while waiting for the desired event to occur. The thread continues if either the event happened or an interrupt was caught. It is likely that a thread using this type will be moved off core when blocked.
-
SPINNING
public static final ThreadType SPINNING
The thread repeatedly checks if the event has arrived using a non-blocking call without pausing in between checks. This thread type effectively monopolizes a core and keeps the thread on core.
-
SPINPARK
public static final ThreadType SPINPARK
This thread repeatedly checks for the event using a non-blocking call but only for a fixed number of times (the spin limit). When the spin limit is reached, the threadparksfor a specified nanosecond time limit. Upon waking up, the threads resets the spin count and starts the repeated, non-blocking checks again. This continues until an event is detected.This type is a compromise between blocking and spinning by aggressively spinning until the event occurs but not entirely monopolizing a core. By parking, the thread may be moved off core but not as likely as in a blocking thread.
-
SPINYIELD
public static final ThreadType SPINYIELD
This thread repeatedly check for the event using a non-blocking call but only for a fixed number of times (the spin limit). When the spin limit is reached, the threadyieldsthe core to another thread. When the thread re-gains the core, the the spin count is reset and the repeated, non-blocking checks start again. This continues until an event is detected.This type is a compromise between blocking and spinning by aggressively spinning until an event occurs but not entirely monopolizing a core. By yielding, the thread may be moved off core but not as likely as in a blocking thread.
-
-
Method Detail
-
values
public static ThreadType[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:for (ThreadType c : ThreadType.values()) System.out.println(c);
- Returns:
- an array containing the constants of this enum type, in the order they are declared
-
valueOf
public static ThreadType valueOf(String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)- Parameters:
name- the name of the enum constant to be returned.- Returns:
- the enum constant with the specified name
- Throws:
IllegalArgumentException- if this enum type has no constant with the specified nameNullPointerException- if the argument is null
-
toString
public String toString()
- Overrides:
toStringin classEnum<ThreadType>
-
textName
public String textName()
Returns the thread type text name.- Returns:
- text name.
-
find
public static ThreadType find(String s)
Returns the thread type with a text name equalings, ignoring case. Will returnnullifsdoes not match any thread type text name.- Parameters:
s- compare the thread type text name to this given value.- Returns:
- thread type for the given text name.
-
-