Thread class. Each Ruby thread is
mapped to an underlying Java Virtual Machine thread.
Thread encapsulates the behavior of a thread of execution, including the main
thread of the Ruby script. In the descriptions that follow, the parameter
aSymbol refers to a symbol, which is either a quoted string or a
Symbol (such as :name).
Note
For CVS history, see ThreadClass.java.
| Modifier and Type | Class and Description |
|---|---|
| public static class | |
| public static interface | RubyThread.
Deprecated
|
| public static class | |
| public static interface | |
| public static interface | |
| public static class | RubyThread.
References Deprecated
RubyThread.BlockingTask is deprecated or references (maybe indirectly) at least one deprecated element.
|
| private static class | RubyThread.
A Task for sleeping. |
| public static enum | RubyThread.
Thread statuses |
| public static interface | |
| public static interface |
| Modifier and Type | Field and Description |
|---|---|
| private volatile boolean | abortOnException
Whether this thread should try to abort the program on exception |
| private final boolean | adopted
Whether this is an "adopted" thread not created by Ruby code |
| private volatile int | |
| private volatile BlockingIO. | |
| private volatile WeakReference | contextRef
Weak reference to the ThreadContext for this thread. |
| private final Map | contextVariables
Context-local variables, internal-ish thread locals |
| private volatile RubyThread. | currentBlockingTask
References Deprecated
RubyThread.BlockingTask is deprecated or references (maybe indirectly) at least one deprecated element.
|
| private volatile Selector | |
| private volatile boolean | disposed
Whether or not this thread has been disposed of |
| private volatile IRubyObject | errorInfo
Per-thread "current exception" |
| private volatile Throwable | exitingException
The exception currently being raised out of the thread. |
| private volatile RubyThread | |
| private transient volatile Map | fiberLocalVariables
Fiber-local variables |
| private String | |
| private volatile IRubyObject | finalResult
The final value resulting from the thread's execution |
| private static final RubyHash. | |
| private final List | heldLocks
The list of locks this thread currently holds, so they can be released on exit |
| private static final AtomicIntegerFieldUpdater | |
| private static final int | |
| private static final int | |
| private static final int | |
| private static final int | |
| private volatile int | interruptFlag
Interrupt flags |
| private volatile int | interruptMask
Interrupt mask to use for disabling certain types |
| private final Vector | interruptMaskStack
Stack of interrupt masks active for this thread |
| private volatile boolean | |
| private int | |
| private static final Logger | |
| private static final RubyHash[] | |
| private static final int | |
| private final Queue | pendingInterruptQueue
Mail slot for cross-thread events |
| private volatile boolean | pendingInterruptQueueChecked
Short circuit to avoid-re-scanning for interrupts |
| private static final int | |
| private volatile boolean | reportOnException
Whether this thread should report_on_exception when this thread GCs, when it terminates, or never |
| public static final int | |
| public static final int | |
| private static final String | |
| private IRubyObject | |
| private final RubyThread. | sleepTask
Thread-local tuple used for sleeping (semaphore, millis, nanos) |
| private volatile RubyThread. | status
Current status in an atomic reference |
| private static final AtomicReferenceFieldUpdater | |
| private volatile RubyThreadGroup | threadGroup
The ThreadGroup to which this thread belongs |
| private volatile ThreadLike | threadImpl
The thread-like think that is actually executing |
| private transient volatile Map | threadLocalVariables
Normal thread-local variables (local to parent thread if in a fiber) |
| private static final int | |
| private static final int | |
| private volatile Object | unblockArg
Argument to pass to the unblocker |
| private volatile RubyThread. | unblockFunc
A function to use to unblock this thread, if possible |
| private static final StackWalker |
| Access | Constructor and Description |
|---|---|
| protected | |
| public |
| Modifier and Type | Method and Description |
|---|---|
| public RubyBoolean | |
| public static RubyBoolean | abort_on_exception(ThreadContext context, IRubyObject recv)
Returns the status of the global ``abort on exception'' condition. |
| public IRubyObject | |
| public static IRubyObject | |
| private boolean | |
| public IRubyObject | |
| public static IRubyObject | |
| private void | |
| public static RubyThread | |
| public static RubyThread | |
| private static RubyThread | adoptThread(final Ruby runtime, final ThreadService service, final RubyClass recv, final Thread thread)
|
| public void | |
| public RubyBoolean | |
| public RubyBoolean | |
| private boolean | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public void | |
| public void | |
| public void | |
| public void | beforeStart()
Perform pre-execution tasks once the native thread is running, but we have not yet called the Ruby code for the thread. |
| public void | |
| private static int | |
| public synchronized void | |
| public void | |
| public void | |
| public void | |
| private static void | |
| public static RubyClass | |
| public static RubyThread | |
| public void | |
| public void | |
| public void | |
| public static IRubyObject | |
| public void | |
| public boolean | equals(Object
object to compare obj)Overrides org. This override does not do a "checked" dispatch. |
| public void | |
| public void | |
| public void | |
| private void | |
| public < the type of the data object Data> int | Returns: the number of bytes writtenthe current context context, Data a data object data, byte[] the bytes to write bytes, int start range of bytes to write start, int length of bytes to write length, RubyThread.the write task taskExecute an interruptible read or write operation with the given byte range and data object. |
| public <Data> int | executeReadWrite(ThreadContext context, Data data, ByteBuffer bytes, int start, int length, RubyThread.
|
| public <Data> int | Returns: ""Execute an interruptible regexp operation with the given function and bytess. |
| public <Data, Return> Return | |
| public <Data, Return> Return | executeTask(ThreadContext context, Data data, RubyThread.
|
| private <Data, Return> Return | executeTask(ThreadContext context, Data data, RubyThread.
|
| public <Data, Return> Return | |
| public <Data, Return> Return | executeTaskBlocking(ThreadContext context, Data data, RubyThread.
|
| public static IRubyObject | |
| public void | |
| public IRubyObject | |
| public IRubyObject | |
| private IRubyObject | |
| private IRubyObject | |
| public ThreadContext | |
| public final Map | |
| public IRubyObject | |
| public Throwable | |
| public RubyThread | |
| private Map | |
| private int | |
| public IRubyObject | |
| public IRubyObject | |
| public Thread | |
| public IRubyObject | |
| public IRubyObject | |
| private RubyThread. | |
| private String | |
| public RubyThreadGroup | |
| private Map | |
| private Map | |
| public IRubyObject | |
| public static IRubyObject | |
| private IRubyObject | handleInterrupt(ThreadContext context, RubyHash mask, BiFunction<ThreadContext, IRubyObject, IRubyObject> block)
|
| private <StateType> IRubyObject | handleInterrupt(ThreadContext context, RubyHash mask, StateType state, BiFunction<ThreadContext, StateType, IRubyObject> block)
|
| public int | hashCode()
Overrides org. This override does not do "checked" dispatch since Object usually has #hash defined. |
| private String | |
| private static long | |
| public void | |
| public IRubyObject | |
| private static void | |
| public RubyString | inspect(ThreadContext context)
Overrides org. Overrides default org. Returns a string containing a human-readable representation of obj. |
| public synchronized void | |
| public boolean | |
| public boolean | |
| public boolean | |
| public boolean | |
| private boolean | |
| public boolean | |
| public StackTraceElement[] | |
| public static int | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| private IRubyObject | |
| public RubyBoolean | |
| public RubyArray | |
| public static IRubyObject | |
| public IRubyObject | |
| public static RubyArray | |
| public void | |
| public void | lockInterruptibly(Lock
the lock to acquire, released on thread termination lock)Acquire the given lock interruptibly, holding a reference to it for cleanup on thread termination. |
| public static RubyThread | |
| public static RubyThread | |
| public IRubyObject | |
| private RubyThread. | |
| public static IRubyObject | newInstance(IRubyObject recv, IRubyObject[] args, Block block)
Thread.new( [ arg ]* ) {| args | block }$ -> aThread Creates a new thread to execute the instructions given in block, and begins running it. |
| private static boolean | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public static IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| public static IRubyObject | |
| private boolean | |
| private int | |
| private void | |
| private IRubyObject | |
| private void | |
| private boolean | |
| public void | |
| public void | pollThreadEvents(ThreadContext
the context context, boolean whether to trigger blocking operation interrupts blocking)Poll for thread events (raise, kill), propagating only events that are unmasked
(see |
| public void | |
| private void | |
| private void | |
| public static IRubyObject | |
| private <Data> void | |
| protected void | |
| public RubyFixnum | |
| public RubyFixnum | |
| public IRubyObject | |
| public IRubyObject | |
| public final IRubyObject | Returns: this threadthe exception to raise exception)Simplified utility method for just raising an existing exception in this thread. |
| public final IRubyObject | Returns: this threadthe exception to raise exception, RubyString the message to use message)Simplified utility method for just raising an existing exception in this thread. |
| public IRubyObject | |
| public IRubyObject | |
| public static IRubyObject | |
| public IRubyObject | |
| public static IRubyObject | |
| public static int | |
| public synchronized IRubyObject | |
| public boolean | Returns: true if the IO's channel became ready for the requested operations, false if it was not selectable.the RubyIO that contains the channel, for managing blocked threads list. io, int the operations to wait for, from ops)java..Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout. |
| public boolean | Returns: true if the IO's channel became ready for the requested operations, false if it timed out or was not selectable.the RubyIO that contains the channel, for managing blocked threads list. io, int the operations to wait for, from ops, long java..a timeout in ms to limit the select. Less than zero selects forever,
zero selects and returns ready channels or nothing immediately, and
greater than zero selects for at most that many ms. timeout)Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout. |
| public boolean | Returns: true if the channel became ready for the requested operations, false if it was not selectable.the channel to perform a select against. If this is not
a selectable channel, then this method will just return true. channel, OpenFile the fptr that contains the channel, for managing blocked threads list. fptr, int the operations to wait for, from ops)java..Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations. |
| public boolean | Returns: true if the channel became ready for the requested operations, false if it was not selectable.the channel to perform a select against. If this is not
a selectable channel, then this method will just return true. channel, RubyIO the RubyIO that contains the channel, for managing blocked threads list. io, int the operations to wait for, from ops)java..Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations. |
| public boolean | Returns: true if the channel became ready for the requested operations, false if it timed out or was not selectable.the channel to perform a select against. If this is not
a selectable channel, then this method will just return true. channel, RubyIO the RubyIO that contains the channel, for managing blocked threads list. io, int the operations to wait for, from ops, long java..a timeout in ms to limit the select. Less than zero selects forever,
zero selects and returns ready channels or nothing immediately, and
greater than zero selects for at most that many ms. timeout)Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout. |
| public boolean | Returns: true if the channel became ready for the requested operations, false if it timed out or was not selectable.the channel to perform a select against. If this is not
a selectable channel, then this method will just return true. channel, OpenFile the fptr that contains the channel, for managing blocked threads list. fptr, int the operations to wait for, from ops, long java..a timeout in ms to limit the select. Less than zero selects forever,
zero selects and returns ready channels or nothing immediately, and
greater than zero selects for at most that many ms. timeout)Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout. |
| public IRubyObject | |
| public void | |
| public void | |
| public IRubyObject | |
| public void | |
| public IRubyObject | |
| public IRubyObject | setFiberScheduler(ThreadContext context, IRubyObject scheduler)
Set the scheduler for the current thread. |
| public void | |
| public IRubyObject | |
| public IRubyObject | |
| public void | |
| pack-priv void | |
| public boolean | sleep(long
Number of milliseconds to sleep. Zero sleeps forever. milliseconds)Sleep the current thread for milliseconds, waking up on any thread interrupts. |
| public boolean | sleep(long
Number of milliseconds to sleep. Combined with nanoseconds, zero sleeps forever. milliseconds, long Number of nanoseconds to sleep. Combined with milliseconds, zero sleeps forever. nanoseconds)Sleep the current thread for milliseconds + nanoseconds, waking up on any thread interrupts. |
| public void | |
| public void | |
| public static RubyThread | |
| public static RubyThread | start(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block)
Basically the same as Thread.new . |
| private Thread | |
| private static RubyThread | |
| protected static RubyThread | |
| public IRubyObject | |
| public IRubyObject | |
| public static IRubyObject | |
| public RubyBoolean | |
| public RubyBoolean | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| public IRubyObject | |
| private void | |
| public <T> T | toJava(final Class<T>
The target type to which the object should be converted (e.g. target)java.lang.Thread.class).Overrides org. Implements org. Customized for retrieving a Java thread from a Ruby one. |
| private void | |
| public String | toString()
Overrides org. The default toString method is just a wrapper that calls the Ruby "to_s" method. |
| public boolean | |
| public static <StateType> IRubyObject | Returns: return value of f.apply.the current context context, StateType state, BiFunction<ThreadContext, StateType, IRubyObject> the bifunction to execute f)Run the provided |
| public void | |
| public void | |
| public IRubyObject | |
| public IRubyObject | |
| public boolean | |
| public boolean | |
| public synchronized RubyThread |