V - The type of the fiber's result value. Should be set to Void if no value is to be returned by the fiber.public class Fiber<V> extends Strand implements Joinable<V>, java.io.Serializable, java.util.concurrent.Future<V>
Fiber class and override the run method,
or pass the code to be executed in the fiber as the target parameter to the constructor. All in all, the Fiber API
resembles the Thread class in many ways.
A fiber runs inside a ForkJoinPool.
A Fiber can be serialized if it's not running and all involved classes and data types are also Serializable.
A new Fiber occupies under 400 bytes of memory (when using the default stack size, and compressed OOPs are turned on, as they are by default).Strand.State, Strand.UncaughtExceptionHandler| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_STACK_SIZE |
protected static FlightRecorder |
flightRecorder |
currentStrand, MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY| Constructor and Description |
|---|
Fiber()
Creates a new child Fiber subclassing the Fiber class and overriding the
run method. |
Fiber(Fiber fiber,
FiberScheduler scheduler,
SuspendableCallable<V> target) |
Fiber(Fiber fiber,
FiberScheduler scheduler,
SuspendableRunnable target) |
Fiber(FiberScheduler scheduler)
Creates a new Fiber subclassing the Fiber class and overriding the
run method. |
Fiber(FiberScheduler scheduler,
SuspendableCallable<V> target)
Creates a new Fiber from the given
SuspendableCallable. |
Fiber(FiberScheduler scheduler,
SuspendableRunnable target)
Creates a new Fiber from the given SuspendableRunnable.
|
Fiber(Fiber fiber,
SuspendableCallable<V> target) |
Fiber(Fiber fiber,
SuspendableRunnable target) |
Fiber(java.lang.String name)
Creates a new child Fiber subclassing the Fiber class and overriding the
run method. |
Fiber(java.lang.String name,
FiberScheduler scheduler)
Creates a new Fiber subclassing the Fiber class and overriding the
run method. |
Fiber(java.lang.String name,
FiberScheduler scheduler,
int stackSize)
Creates a new Fiber subclassing the Fiber class and overriding the
run method. |
Fiber(java.lang.String name,
FiberScheduler scheduler,
int stackSize,
SuspendableCallable<V> target)
Creates a new fiber from the given
SuspendableCallable. |
Fiber(java.lang.String name,
FiberScheduler scheduler,
int stackSize,
SuspendableRunnable target)
Creates a new Fiber from the given
SuspendableRunnable. |
Fiber(java.lang.String name,
FiberScheduler scheduler,
SuspendableCallable<V> target)
Creates a new Fiber from the given
SuspendableCallable. |
Fiber(java.lang.String name,
FiberScheduler scheduler,
SuspendableRunnable target)
Creates a new Fiber from the given
SuspendableRunnable. |
Fiber(java.lang.String name,
int stackSize)
Creates a new child Fiber subclassing the Fiber class and overriding the
run method. |
Fiber(java.lang.String name,
int stackSize,
SuspendableCallable<V> target)
Creates a new fiber from the given
SuspendableCallable scheduled in the default fiber scheduler |
Fiber(java.lang.String name,
int stackSize,
SuspendableRunnable target)
Creates a new child Fiber from the given
SuspendableRunnable. |
Fiber(java.lang.String name,
SuspendableCallable<V> target)
Creates a new child Fiber from the given
SuspendableCallable. |
Fiber(java.lang.String name,
SuspendableRunnable target)
Creates a new child Fiber from the given
SuspendableRunnable. |
Fiber(SuspendableCallable<V> target)
Creates a new child Fiber from the given
SuspendableCallable. |
Fiber(SuspendableRunnable target)
Creates a new child Fiber from the given
SuspendableRunnable. |
| Modifier and Type | Method and Description |
|---|---|
boolean |
cancel(boolean mayInterruptIfRunning) |
static Fiber |
currentFiber()
Returns the active Fiber on this thread or NULL if no Fiber is running.
|
static void |
dumpStack() |
boolean |
equals(java.lang.Object obj) |
V |
get() |
V |
get(long timeout,
java.util.concurrent.TimeUnit unit) |
java.lang.Object |
getBlocker()
Returns the blocker object supplied to the most recent
invocation of a
park method that has not yet unblocked, or null
if not blocked. |
static long |
getCurrentRun() |
static Strand.UncaughtExceptionHandler |
getDefaultUncaughtExceptionHandler()
Returns the default handler invoked when a fiber abruptly terminates
due to an uncaught exception.
|
static ByteArraySerializer |
getFiberSerializer()
Returns a
ByteArraySerializer capable of serializing an object graph containing fibers. |
static ByteArraySerializer |
getFiberSerializer(boolean includeThreadLocals)
Returns a
ByteArraySerializer capable of serializing an object graph containing fibers. |
long |
getId()
Returns the strand's id.
|
java.lang.InterruptedException |
getInterruptStack()
Returns an
InterruptedException that was created when the Strand.interrupt() method was called, and can be used
to retrieve the stack trace of the strand that interrupted this strand. |
FibersMonitor |
getMonitor() |
java.lang.String |
getName()
Returns the strand's name.
|
boolean |
getNoLocals()
Deprecated.
|
int |
getPriority()
Returns this fiber's priority.
|
FiberScheduler |
getScheduler() |
java.lang.StackTraceElement[] |
getStackTrace()
Returns an array of stack trace elements representing the stack dump
of this strand.
|
Strand.State |
getState()
Returns the strand's current running state.
|
SuspendableCallable<V> |
getTarget() |
java.lang.Object |
getTask() |
Strand.UncaughtExceptionHandler |
getUncaughtExceptionHandler()
Returns the handler invoked when this fiber abruptly terminates
due to an uncaught exception.
|
java.lang.Object |
getUnderlying()
Returns the underlying object of this strand, namely a
Thread or a Fiber. |
int |
hashCode() |
Fiber |
inheritThreadLocals()
Causes the current strand's
thread-locals to be inherited by this fiber. |
void |
interrupt()
Interrupts this strand.
|
static boolean |
interrupted() |
boolean |
isAlive()
Tests whether this strand is alive, namely it has been started but not yet terminated.
|
boolean |
isCancelled() |
static boolean |
isCurrentFiber()
Tests whether current code is executing in a fiber.
|
boolean |
isDone() |
boolean |
isFiber()
Tests whether this strand is a fiber.
|
boolean |
isInterrupted()
Tests whether this strand has been interrupted.
|
protected boolean |
isRecordingLevel(int level) |
boolean |
isTerminated()
Tests whether this strand has terminated.
|
void |
join()
Awaits the termination of this strand.
|
void |
join(long timeout,
java.util.concurrent.TimeUnit unit)
Awaits the termination of this strand, at most for the timeout duration specified.
|
Fiber<V> |
joinNoSuspend() |
Fiber<V> |
joinNoSuspend(long timeout,
java.util.concurrent.TimeUnit unit) |
protected void |
onCompletion() |
protected void |
onException(java.lang.Throwable t) |
protected void |
onParked() |
protected void |
onResume() |
static void |
park() |
static void |
park(long timeout,
java.util.concurrent.TimeUnit unit) |
static void |
park(java.lang.Object blocker) |
static boolean |
park(java.lang.Object blocker,
long timeout,
java.util.concurrent.TimeUnit unit) |
static void |
parkAndSerialize(FiberWriter writer)
Parks the fiber and allows the given callback to serialize it.
|
static void |
parkAndUnpark(Fiber other) |
static void |
parkAndUnpark(Fiber other,
java.lang.Object blocker) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object... args) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4,
java.lang.Object arg5) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4,
java.lang.Object arg5,
java.lang.Object arg6) |
protected void |
record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4,
java.lang.Object arg5,
java.lang.Object arg6,
java.lang.Object arg7) |
protected V |
run() |
static void |
setDefaultUncaughtExceptionHandler(Strand.UncaughtExceptionHandler eh)
Set the default handler invoked when a fiber abruptly terminates
due to an uncaught exception, and no other handler has been defined
for that fiber.
|
Fiber<V> |
setName(java.lang.String name)
Sets this strand's name.
|
Fiber |
setNoLocals(boolean value)
Deprecated.
|
Fiber |
setPriority(int newPriority)
Sets the priority of this fiber.
|
void |
setUncaughtExceptionHandler(Strand.UncaughtExceptionHandler eh)
Set the handler invoked when this fiber abruptly terminates
due to an uncaught exception.
|
protected boolean |
shouldPreempt(int type) |
static void |
sleep(long millis) |
static void |
sleep(long millis,
int nanos) |
static void |
sleep(long duration,
java.util.concurrent.TimeUnit unit) |
Fiber<V> |
start()
Starts the strand.
|
java.lang.String |
toString() |
void |
unpark()
Makes available the permit for this fiber, if it was not already available.
|
void |
unpark(java.lang.Object unblocker)
Makes available the permit for this strand, if it
was not already available.
|
static <V> Fiber<V> |
unparkDeserialized(Fiber<V> f,
FiberScheduler scheduler)
Unparks a fiber that's been deserialized (with the help of
getFiberSerializer() |
static <V> Fiber<V> |
unparkSerialized(byte[] serFiber,
FiberScheduler scheduler)
Deserializes a fiber from the given byte array and unparks it.
|
static void |
yield() |
static void |
yieldAndUnpark(Fiber other) |
static void |
yieldAndUnpark(Fiber other,
java.lang.Object blocker) |
clone, clone, currentStrand, equals, join, join, of, of, of, parkAndUnpark, parkAndUnpark, parkNanos, parkNanos, parkUntil, printStackTrace, printStackTrace, toRunnable, toRunnable, toString, unpark, unpark, unpark, unwrapSuspendable, yieldAndUnpark, yieldAndUnparkpublic static final int DEFAULT_STACK_SIZE
protected static final FlightRecorder flightRecorder
public Fiber(java.lang.String name,
FiberScheduler scheduler,
int stackSize,
SuspendableCallable<V> target)
SuspendableCallable.name - The name of the fiber (may be null)scheduler - The FiberScheduler that will schedule the fiber.stackSize - the initial size of the data stack.target - the SuspendableCallable for the fiber. May null if the run method is overriden.public Fiber(java.lang.String name,
int stackSize,
SuspendableCallable<V> target)
SuspendableCallable scheduled in the default fiber schedulername - The name of the fiber (may be null)stackSize - the initial size of the data stack.target - the SuspendableCallable for the fiber. May null if the run method is overriden.public Fiber(java.lang.String name,
FiberScheduler scheduler,
SuspendableCallable<V> target)
SuspendableCallable.
The new fiber uses the default initial stack size.name - The name of the fiber (may be null)scheduler - The scheduler pool in which the fiber should run.target - the SuspendableCallable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(FiberScheduler scheduler, SuspendableCallable<V> target)
SuspendableCallable.
The new fiber has no name, and uses the default initial stack size.scheduler - The scheduler pool in which the fiber should run.target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
FiberScheduler scheduler,
int stackSize,
SuspendableRunnable target)
SuspendableRunnable.name - The name of the fiber (may be null)scheduler - The scheduler pool in which the fiber should run.stackSize - the initial size of the data stack.target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
FiberScheduler scheduler,
SuspendableRunnable target)
SuspendableRunnable.
The new fiber uses the default initial stack size.name - The name of the fiber (may be null)scheduler - The scheduler pool in which the fiber should run.target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(FiberScheduler scheduler, SuspendableRunnable target)
scheduler - The scheduler pool in which the fiber should run.target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
FiberScheduler scheduler,
int stackSize)
run method.name - The name of the fiber (may be null)scheduler - The scheduler pool in which the fiber should run.stackSize - the initial size of the data stack.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
FiberScheduler scheduler)
run method.
The new fiber uses the default initial stack size.name - The name of the fiber (may be null)scheduler - The scheduler pool in which the fiber should run.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(FiberScheduler scheduler)
run method.
The new fiber has no name, and uses the default initial stack size.scheduler - The scheduler pool in which the fiber should run.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
SuspendableCallable<V> target)
SuspendableCallable.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
The new fiber uses the default initial stack size.name - The name of the fiber (may be null)target - the SuspendableRunnable for the Fiber.java.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(SuspendableCallable<V> target)
SuspendableCallable.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
The new fiber has no name, and uses the default initial stack size.target - the SuspendableRunnable for the Fiber.java.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
int stackSize,
SuspendableRunnable target)
SuspendableRunnable.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.name - The name of the fiber (may be null)stackSize - the initial size of the data stack.target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
SuspendableRunnable target)
SuspendableRunnable.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
The new fiber uses the default initial stack size.name - The name of the fiber (may be null)target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(SuspendableRunnable target)
SuspendableRunnable.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
The new fiber has no name, and uses the default initial stack size.target - the SuspendableRunnable for the Fiber.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name,
int stackSize)
run method.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.name - The name of the fiber (may be null)stackSize - the initial size of the data stack.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(java.lang.String name)
run method.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
The new fiber uses the default initial stack size.name - The name of the fiber (may be null)java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber()
run method.
This constructor may only be called from within another fiber. This fiber will use the same fork/join pool as the creating fiber.
The new fiber has no name, and uses the default initial stack size.java.lang.NullPointerException - when proto is nulljava.lang.IllegalArgumentException - when stackSize is <= 0public Fiber(Fiber fiber, SuspendableCallable<V> target)
public Fiber(Fiber fiber, SuspendableRunnable target)
public Fiber(Fiber fiber, FiberScheduler scheduler, SuspendableCallable<V> target)
public Fiber(Fiber fiber, FiberScheduler scheduler, SuspendableRunnable target)
public final SuspendableCallable<V> getTarget()
public final int hashCode()
hashCode in class java.lang.Objectpublic final boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic final java.lang.String getName()
Strandpublic final Fiber<V> setName(java.lang.String name)
Strandpublic Fiber setPriority(int newPriority)
setPriority in class StrandnewPriority - priority to set this fiber tojava.lang.IllegalArgumentException - If the priority is not in the
range MIN_PRIORITY to MAX_PRIORITYgetPriority(),
Strand.MAX_PRIORITY,
Strand.MIN_PRIORITYpublic int getPriority()
getPriority in class StrandsetPriority(int)public long getId()
Strandpublic java.lang.Object getTask()
public FiberScheduler getScheduler()
@Deprecated public Fiber setNoLocals(boolean value)
@Deprecated public boolean getNoLocals()
public static Fiber currentFiber()
public static boolean isCurrentFiber()
Fiber.currentFiber() != null.true if called in a fiber; false otherwise.public static long getCurrentRun()
public final boolean isFiber()
Strandpublic final java.lang.Object getUnderlying()
StrandThread or a Fiber.getUnderlying in class Strandpublic static boolean park(java.lang.Object blocker,
long timeout,
java.util.concurrent.TimeUnit unit)
throws SuspendExecution
SuspendExecutionpublic static void park(java.lang.Object blocker)
throws SuspendExecution
SuspendExecutionpublic static void park(long timeout,
java.util.concurrent.TimeUnit unit)
throws SuspendExecution
SuspendExecutionpublic static void park()
throws SuspendExecution
SuspendExecutionpublic static void yield()
throws SuspendExecution
SuspendExecutionpublic static void parkAndUnpark(Fiber other) throws SuspendExecution
SuspendExecutionpublic static void parkAndUnpark(Fiber other, java.lang.Object blocker) throws SuspendExecution
SuspendExecutionpublic static void yieldAndUnpark(Fiber other, java.lang.Object blocker) throws SuspendExecution
SuspendExecutionpublic static void yieldAndUnpark(Fiber other) throws SuspendExecution
SuspendExecutionpublic static void sleep(long millis)
throws java.lang.InterruptedException,
SuspendExecution
java.lang.InterruptedExceptionSuspendExecutionpublic static void sleep(long millis,
int nanos)
throws java.lang.InterruptedException,
SuspendExecution
java.lang.InterruptedExceptionSuspendExecutionpublic static void sleep(long duration,
java.util.concurrent.TimeUnit unit)
throws java.lang.InterruptedException,
SuspendExecution
java.lang.InterruptedExceptionSuspendExecutionpublic static boolean interrupted()
public FibersMonitor getMonitor()
protected V run() throws SuspendExecution, java.lang.InterruptedException
SuspendExecutionjava.lang.InterruptedExceptionpublic Fiber inheritThreadLocals()
thread-locals to be inherited by this fiber. By default only InheritableThreadLocals
are inherited.
This method must be called before the fiber is started (i.e. before the start method is called.
Otherwise, an IllegalStateException is thrown.thisprotected void onParked()
protected void onResume()
throws SuspendExecution,
java.lang.InterruptedException
SuspendExecutionjava.lang.InterruptedExceptionprotected boolean shouldPreempt(int type)
protected void onCompletion()
protected void onException(java.lang.Throwable t)
public final void interrupt()
StrandInterruptedException.
Otherwise, the strand may test its interrupted status with the Strand.interrupted() or Strand.isInterrupted() method.public final boolean isInterrupted()
StrandisInterrupted in class Strandtrue if the strand has been interrupted; false otherwise.Strand.interrupt(),
Strand.interrupted()public final java.lang.InterruptedException getInterruptStack()
StrandInterruptedException that was created when the Strand.interrupt() method was called, and can be used
to retrieve the stack trace of the strand that interrupted this strand.
This method is only intended to assist in debugging.
This method may return null if this information is not available. The current implementation always returns null
if this strand is a thread.getInterruptStack in class Strandpublic final boolean isAlive()
Strandpublic final Strand.State getState()
Strandpublic final boolean isTerminated()
StrandisTerminated in class Strandpublic final java.lang.Object getBlocker()
Strandpark method that has not yet unblocked, or null
if not blocked. The value returned is just a momentary
snapshot -- the thread may have since unblocked or blocked on a
different blocker object.getBlocker in class Strandpublic final void unpark()
park then it will unblock.
Otherwise, its next call to park is guaranteed not to block.public final void unpark(java.lang.Object unblocker)
StrandStrand.park() then it will unblock. Otherwise, its next call
to Strand.park() is guaranteed not to block. This operation
is not guaranteed to have any effect at all if the given
strand has not been started.@Suspendable public final void join() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
Strand@Suspendable public final void join(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
Strandjoin in interface Joinable<V>join in class Strandtimeout - the maximum duration to wait for the strand to terminate in the time unit specified by unit.unit - the time unit of timeout.java.util.concurrent.ExecutionException - if this strand has terminated as a result of an uncaught exception
(which will be the cause of the thrown ExecutionException.java.util.concurrent.TimeoutException - if this strand did not terminate by the time the timeout has elapsed.java.lang.InterruptedExceptionpublic final Fiber<V> joinNoSuspend() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
java.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionpublic final Fiber<V> joinNoSuspend(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
java.util.concurrent.ExecutionExceptionjava.lang.InterruptedExceptionjava.util.concurrent.TimeoutException@Suspendable public final V get() throws java.util.concurrent.ExecutionException, java.lang.InterruptedException
@Suspendable public final V get(long timeout, java.util.concurrent.TimeUnit unit) throws java.util.concurrent.ExecutionException, java.lang.InterruptedException, java.util.concurrent.TimeoutException
public final boolean isDone()
public final boolean cancel(boolean mayInterruptIfRunning)
cancel in interface java.util.concurrent.Future<V>public final boolean isCancelled()
isCancelled in interface java.util.concurrent.Future<V>public final void setUncaughtExceptionHandler(Strand.UncaughtExceptionHandler eh)
A fiber can take full control of how it responds to uncaught exceptions by having its uncaught exception handler explicitly set.
setUncaughtExceptionHandler in class Strandeh - the object to use as this fiber's uncaught exception
handler. If null then this fiber has no explicit handler.setDefaultUncaughtExceptionHandler(co.paralleluniverse.strands.Strand.UncaughtExceptionHandler)public final Strand.UncaughtExceptionHandler getUncaughtExceptionHandler()
getUncaughtExceptionHandler in class Strandpublic static Strand.UncaughtExceptionHandler getDefaultUncaughtExceptionHandler()
null,
there is no default.public static void setDefaultUncaughtExceptionHandler(Strand.UncaughtExceptionHandler eh)
eh - the object to use as the default uncaught exception handler.
If null then there is no default handler.setUncaughtExceptionHandler(co.paralleluniverse.strands.Strand.UncaughtExceptionHandler),
getUncaughtExceptionHandler()public final java.lang.StackTraceElement[] getStackTrace()
StrandSome virtual machines may, under some circumstances, omit one or more stack frames from the stack trace. In the extreme case, a virtual machine that has no stack trace information concerning this strand is permitted to return a zero-length array from this method.
getStackTrace in class StrandStackTraceElements, each represents one stack frame.public static void dumpStack()
public final java.lang.String toString()
toString in class java.lang.Objectprotected final boolean isRecordingLevel(int level)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4,
java.lang.Object arg5)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4,
java.lang.Object arg5,
java.lang.Object arg6)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object arg1,
java.lang.Object arg2,
java.lang.Object arg3,
java.lang.Object arg4,
java.lang.Object arg5,
java.lang.Object arg6,
java.lang.Object arg7)
protected final void record(int level,
java.lang.String clazz,
java.lang.String method,
java.lang.String format,
java.lang.Object... args)
public static void parkAndSerialize(FiberWriter writer) throws SuspendExecution
writer - a callback that can serialize the fiber.SuspendExecutionpublic static <V> Fiber<V> unparkSerialized(byte[] serFiber, FiberScheduler scheduler)
serFiber - The byte array containing a fiber's serialized form.scheduler - The FiberScheduler to use for scheduling the fiber.public static <V> Fiber<V> unparkDeserialized(Fiber<V> f, FiberScheduler scheduler)
getFiberSerializer()f - The deserialized fiberscheduler - The FiberScheduler to use for scheduling the fiber.public static ByteArraySerializer getFiberSerializer()
ByteArraySerializer capable of serializing an object graph containing fibers.public static ByteArraySerializer getFiberSerializer(boolean includeThreadLocals)
ByteArraySerializer capable of serializing an object graph containing fibers.includeThreadLocals - if true, thread/fiber local storage slots will also be serialised.
You may want to set this to false if you are using frameworks that put
things that cannot be properly serialised into TLS slots, or if the feature
causes other issues.