Module java.base

Class WispEngine

  • All Implemented Interfaces:
    Executor, ExecutorService

    public class WispEngine
    extends AbstractExecutorService
    Coroutine Runtime Engine. It's a "wisp" thing, as we want our asynchronization transformation to be transparent without any modification to user code.

    WispEngine represents a group of WispCarrier, which can steal tasks from each other to achieve work-stealing.

    WispEngine#WISP_ROOT_ENGINE is created by system. {@link WispEngine#current().execute(Runnable)} in non-worker thread and WISP_ROOT_ENGINE's worker thread will dispatch task in this carrier.

    User code could also create WispEngine by calling createEngine(int, ThreadFactory), Calling Executor.execute(Runnable) will dispatch WispTask inner created carrier. {@link WispEngine#current().execute(Runnable)} in a user created carrier will also dispatch task in current carrier.

    • Method Detail

      • transparentWispSwitch

        public static boolean transparentWispSwitch()
      • enableThreadAsWisp

        public static boolean enableThreadAsWisp()
      • isTransparentAsync

        @Deprecated
        public static boolean isTransparentAsync()
        Deprecated.
      • createEngine

        public static WispEngine createEngine​(int size,
                                              ThreadFactory tf)
        Create a new WispEngine for executing tasks.
        Parameters:
        size - worker thread counter
        tf - ThreadFactory used to create worker thread
      • dispatch

        public static void dispatch​(Runnable target)
        Create WispTask to run task code

        The real running thread depends on implementation

        Parameters:
        target - target code
      • isShiftThreadModel

        @Deprecated
        public static boolean isShiftThreadModel()
        Deprecated.
      • getWispCounter

        public static WispCounter getWispCounter​(long id)
      • getManagedEngineCounters

        public static Map<Long,​WispCounter> getManagedEngineCounters()
      • getWispCarrierIds

        public List<Long> getWispCarrierIds()