Enum ThreadSelection

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Comparable<ThreadSelection>

    public enum ThreadSelection
    extends java.lang.Enum<ThreadSelection>
    Enum the controls the ability to select threads in a Micronaut application.
    Since:
    1.3
    • Enum Constant Summary

      Enum Constants 
      Enum Constant Description
      AUTO
      Automatically select the thread to run operations on based on the return type and/or Blocking or NonBlocking annotations.
      IO
      I/O selection will run all operations regardless of return type and annotations on the I/O thread pool and will never schedule an operation on the server event loop thread.
      MANUAL
      Manual selection leaves it up to the user code to spawn threads to run any blocking I/O operations.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static ThreadSelection valueOf​(java.lang.String name)
      Returns the enum constant of this type with the specified name.
      static ThreadSelection[] values()
      Returns an array containing the constants of this enum type, in the order they are declared.
      • Methods inherited from class java.lang.Enum

        clone, compareTo, equals, finalize, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
      • Methods inherited from class java.lang.Object

        getClass, notify, notifyAll, wait, wait, wait
    • Enum Constant Detail

      • AUTO

        public static final ThreadSelection AUTO
        Automatically select the thread to run operations on based on the return type and/or Blocking or NonBlocking annotations.

        This is the default strategy in 1.x and will run operations on the I/O thread pool if the return type of the method is not a reactive top and the method is not annotated with NonBlocking

        If the return type is a reactive type and the method is not annotated with Blocking then the server event loop thread will used to run the operation.

      • MANUAL

        public static final ThreadSelection MANUAL
        Manual selection leaves it up to the user code to spawn threads to run any blocking I/O operations. This could be via an appropriate call to subscribeOn(..) or by using the Async annotation or whatever mechanism the user chooses to spawn the additional thread.
      • IO

        public static final ThreadSelection IO
        I/O selection will run all operations regardless of return type and annotations on the I/O thread pool and will never schedule an operation on the server event loop thread.
    • Method Detail

      • values

        public static ThreadSelection[] 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 (ThreadSelection c : ThreadSelection.values())
            System.out.println(c);
        
        Returns:
        an array containing the constants of this enum type, in the order they are declared
      • valueOf

        public static ThreadSelection valueOf​(java.lang.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:
        java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
        java.lang.NullPointerException - if the argument is null