Package org.jruby

Class RubyThread

All Implemented Interfaces:
Serializable, Cloneable, Comparable<IRubyObject>, InstanceVariables, InternalVariables, IRubyObject, ExecutionContext, CoreObjectType

public class RubyThread extends RubyObject implements ExecutionContext
Implementation of Ruby's 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.

See Also:
  • Field Details

    • LOG

      private static final Logger LOG
    • WALKER

      private static final com.headius.backport9.stack.StackWalker WALKER
    • threadImpl

      private volatile ThreadLike threadImpl
      The thread-like think that is actually executing
    • fiberLocalVariables

      private transient volatile Map<IRubyObject,IRubyObject> fiberLocalVariables
      Fiber-local variables
    • threadLocalVariables

      private transient volatile Map<IRubyObject,IRubyObject> threadLocalVariables
      Normal thread-local variables (local to parent thread if in a fiber)
    • contextVariables

      private final Map<Object,IRubyObject> contextVariables
      Context-local variables, internal-ish thread locals
    • abortOnException

      private volatile boolean abortOnException
      Whether this thread should try to abort the program on exception
    • reportOnException

      private volatile boolean reportOnException
      Whether this thread should report_on_exception when this thread GCs, when it terminates, or never
    • finalResult

      private volatile IRubyObject finalResult
      The final value resulting from the thread's execution
    • file

      private String file
    • line

      private int line
    • exitingException

      private volatile Throwable exitingException
      The exception currently being raised out of the thread. We reference it here to continue propagating it while handling thread shutdown logic and abort_on_exception.
    • threadGroup

      private volatile RubyThreadGroup threadGroup
      The ThreadGroup to which this thread belongs
    • errorInfo

      private volatile IRubyObject errorInfo
      Per-thread "current exception"
    • contextRef

      private volatile WeakReference<ThreadContext> contextRef
      Weak reference to the ThreadContext for this thread.
    • interruptMaskStack

      private final Vector<RubyHash> interruptMaskStack
      Stack of interrupt masks active for this thread
    • sleepTask

      private final RubyThread.SleepTask2 sleepTask
      Thread-local tuple used for sleeping (semaphore, millis, nanos)
    • adopted

      private final boolean adopted
      Whether this is an "adopted" thread not created by Ruby code
    • RUBY_MIN_THREAD_PRIORITY

      public static final int RUBY_MIN_THREAD_PRIORITY
      See Also:
    • RUBY_MAX_THREAD_PRIORITY

      public static final int RUBY_MAX_THREAD_PRIORITY
      See Also:
    • status

      private volatile RubyThread.Status status
      Current status in an atomic reference
    • STATUS

    • pendingInterruptQueue

      private final Queue<IRubyObject> pendingInterruptQueue
      Mail slot for cross-thread events
    • unblockFunc

      private volatile RubyThread.Unblocker unblockFunc
      A function to use to unblock this thread, if possible
    • unblockArg

      private volatile Object unblockArg
      Argument to pass to the unblocker
    • heldLocks

      private final List<Lock> heldLocks
      The list of locks this thread currently holds, so they can be released on exit
    • disposed

      private volatile boolean disposed
      Whether or not this thread has been disposed of
    • interruptFlag

      private volatile int interruptFlag
      Interrupt flags
    • interruptMask

      private volatile int interruptMask
      Interrupt mask to use for disabling certain types
    • pendingInterruptQueueChecked

      private volatile boolean pendingInterruptQueueChecked
      Short circuit to avoid-re-scanning for interrupts
    • currentSelector

      private volatile Selector currentSelector
    • fiberCurrentThread

      private volatile RubyThread fiberCurrentThread
    • INTERRUPT_FLAG_UPDATER

      private static final AtomicIntegerFieldUpdater<RubyThread> INTERRUPT_FLAG_UPDATER
    • TIMER_INTERRUPT_MASK

      private static final int TIMER_INTERRUPT_MASK
      See Also:
    • PENDING_INTERRUPT_MASK

      private static final int PENDING_INTERRUPT_MASK
      See Also:
    • POSTPONED_JOB_INTERRUPT_MASK

      private static final int POSTPONED_JOB_INTERRUPT_MASK
      See Also:
    • TRAP_INTERRUPT_MASK

      private static final int TRAP_INTERRUPT_MASK
      See Also:
    • INTERRUPT_NONE

      private static final int INTERRUPT_NONE
      See Also:
    • INTERRUPT_IMMEDIATE

      private static final int INTERRUPT_IMMEDIATE
      See Also:
    • INTERRUPT_ON_BLOCKING

      private static final int INTERRUPT_ON_BLOCKING
      See Also:
    • INTERRUPT_NEVER

      private static final int INTERRUPT_NEVER
      See Also:
    • NULL_ARRAY

      private static final RubyHash[] NULL_ARRAY
    • RUBY_THREAD_PREFIX

      private static final String RUBY_THREAD_PREFIX
      See Also:
    • HandleInterruptVisitor

      private static final RubyHash.VisitorWithState HandleInterruptVisitor
    • blockingIO

      private volatile BlockingIO.Condition blockingIO
    • MUTEX_FOR_THREAD_EXCLUSIVE

      private static final String MUTEX_FOR_THREAD_EXCLUSIVE
      See Also:
    • currentBlockingTask

      @Deprecated private volatile RubyThread.BlockingTask currentBlockingTask
      Deprecated.
  • Constructor Details

  • Method Details