- java.lang.Object
-
- java.util.concurrent.AbstractExecutorService
-
- com.alibaba.wisp.engine.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_ENGINEis 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
WispEngineby callingcreateEngine(int, ThreadFactory), CallingExecutor.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 Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static WispEnginecreateEngine(int size, ThreadFactory tf)Create a new WispEngine for executing tasks.static WispEnginecurrent()static voiddispatch(Runnable target)Create WispTask to run task codestatic booleanenableThreadAsWisp()static Map<Long,WispCounter>getManagedEngineCounters()List<Long>getWispCarrierIds()static WispCountergetWispCounter(long id)static booleanisShiftThreadModel()Deprecated.static booleanisTransparentAsync()Deprecated.static booleantransparentWispSwitch()-
Methods declared in class java.util.concurrent.AbstractExecutorService
newTaskFor, newTaskFor, submit, submit, submit
-
Methods declared in class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods declared in interface java.util.concurrent.ExecutorService
awaitTermination, invokeAll, invokeAll, invokeAny, invokeAny, isShutdown, isTerminated, shutdown, shutdownNow
-
-
-
-
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 countertf- ThreadFactory used to create worker thread
-
current
public static WispEngine current()
-
dispatch
public static void dispatch(Runnable target)
Create WispTask to run task codeThe 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()
-
-