Package org.jruby
Class RubyThread
java.lang.Object
org.jruby.RubyBasicObject
org.jruby.RubyObject
org.jruby.RubyThread
- All Implemented Interfaces:
Serializable
,Cloneable
,Comparable<IRubyObject>
,InstanceVariables
,InternalVariables
,IRubyObject
,ExecutionContext
,CoreObjectType
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:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
static interface
Deprecated.static class
static interface
static interface
static final class
static enum
Thread statusesstatic interface
static interface
Nested classes/interfaces inherited from class org.jruby.RubyObject
RubyObject.Data
Nested classes/interfaces inherited from class org.jruby.RubyBasicObject
RubyBasicObject.Finalizer
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
static final int
Fields inherited from class org.jruby.RubyObject
IVAR_INSPECTING_OBJECT_ALLOCATOR, OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
Fields inherited from class org.jruby.RubyBasicObject
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, IS_OVERLAID_F, metaClass, NEVER, NIL_F, REFINED_MODULE_F, STAMP_OFFSET, TAINTED_F, UNDEF, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F, USER9_F, USERA_F, VAR_TABLE_OFFSET, varTable, varTableStamp
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RubyThread
(Ruby runtime, RubyClass type, boolean adopted) RubyThread
(Ruby runtime, RubyClass klass, Runnable runnable) -
Method Summary
Modifier and TypeMethodDescriptionabort_on_exception
(ThreadContext context) static RubyBoolean
abort_on_exception
(ThreadContext context, IRubyObject recv) Returns the status of the global ``abort on exception'' condition.static IRubyObject
abort_on_exception_set
(ThreadContext context, IRubyObject recv, IRubyObject value) add_trace_func
(ThreadContext context, IRubyObject trace_func, Block block) static IRubyObject
add_trace_func
(ThreadContext context, IRubyObject recv, IRubyObject trace_func, Block block) static RubyThread
adopt
(Ruby runtime, ThreadService service, Thread thread) static RubyThread
adopt
(IRubyObject recv, Thread t) void
alive_p()
Deprecated.alive_p
(ThreadContext context) backtrace
(ThreadContext context) backtrace
(ThreadContext context, IRubyObject level) backtrace
(ThreadContext context, IRubyObject level, IRubyObject length) backtrace_locations
(ThreadContext context) backtrace_locations
(ThreadContext context, IRubyObject level) backtrace_locations
(ThreadContext context, IRubyObject level, IRubyObject length) void
beDead()
void
Deprecated.void
beforeBlockingCall
(ThreadContext context) void
Perform pre-execution tasks once the native thread is running, but we have not yet called the Ruby code for the thread.void
blockingThreadPoll
(ThreadContext context) void
cleanTerminate
(IRubyObject result) void
void
Clear the fiber local variable storage for this thread.void
Clear the thread local variable storage for this thread.static RubyClass
createThreadClass
(ThreadContext context, RubyClass Object) static RubyThread
current
(IRubyObject recv) void
void
Used for finalizers that need to kill a Ruby thread.void
dispose()
Dispose of the current thread by tidying up connections to other stuffstatic IRubyObject
each_caller_location
(ThreadContext context, IRubyObject recv, Block block) void
boolean
This override does not do a "checked" dispatch.void
exceptionRaised
(Throwable throwable) For handling all exceptions bubbling out of threadsvoid
exceptionRaised
(RaiseException exception) void
Deprecated.<Data> int
executeReadWrite
(ThreadContext context, Data data, byte[] bytes, int start, int length, RubyThread.ReadWrite<Data> task) Execute an interruptible read or write operation with the given byte range and data object.<Data> int
executeReadWrite
(ThreadContext context, Data data, ByteBuffer bytes, int start, int length, RubyThread.ReadWrite<Data> task) <Data> int
executeRegexp
(ThreadContext context, org.joni.Matcher matcher, int start, int range, int option, RubyThread.RegexMatch task) Execute an interruptible regexp operation with the given function and bytess.<Data,
Return>
ReturnexecuteTask
(ThreadContext context, Data data, RubyThread.Status status, RubyThread.Task<Data, Return> task) <Data,
Return>
ReturnexecuteTask
(ThreadContext context, Data data, RubyThread.Task<Data, Return> task) <Data,
Return>
ReturnexecuteTaskBlocking
(ThreadContext context, Data data, RubyThread.Status status, RubyThread.Task<Data, Return> task) <Data,
Return>
ReturnexecuteTaskBlocking
(ThreadContext context, Data data, RubyThread.Task<Data, Return> task) static IRubyObject
exit
(IRubyObject receiver, Block block) void
fetch
(ThreadContext context, IRubyObject key, Block block) fetch
(ThreadContext context, IRubyObject key, IRubyObject _default, Block block) final Map
<Object, IRubyObject> getName()
Deprecated.getName
(ThreadContext context) group()
static IRubyObject
handle_interrupt
(ThreadContext context, IRubyObject self, IRubyObject _mask, Block block) int
hashCode()
This override does not do "checked" dispatch since Object usually has #hash defined.void
initialize
(ThreadContext context, IRubyObject[] args, Block block) inspect
(ThreadContext context) Returns a string containing a human-readable representation of obj.void
boolean
boolean
boolean
isAlive()
boolean
boolean
static int
javaPriorityToRubyPriority
(int javaPriority) join
(ThreadContext context) join
(ThreadContext context, IRubyObject timeout) join
(ThreadContext context, IRubyObject[] args) Deprecated.key_p
(ThreadContext context, IRubyObject key) keys()
kill()
static IRubyObject
kill
(IRubyObject recv, IRubyObject rubyThread, Block block) static RubyArray
list
(IRubyObject recv) void
Acquire the given lock, holding a reference to it for cleanup on thread termination.void
lockInterruptibly
(Lock lock) Acquire the given lock interruptibly, holding a reference to it for cleanup on thread termination.static RubyThread
main
(IRubyObject recv) static RubyThread
mainThread
(IRubyObject receiver) native_thread_id
(ThreadContext context) static IRubyObject
newInstance
(IRubyObject recv, IRubyObject[] args, Block block) Thread.new
op_aref
(ThreadContext context, IRubyObject key) op_aset
(IRubyObject key, IRubyObject value) Deprecated.op_aset
(ThreadContext context, IRubyObject key, IRubyObject value) static IRubyObject
pass
(ThreadContext context, IRubyObject recv) pending_interrupt_p
(ThreadContext context) pending_interrupt_p
(ThreadContext context, IRubyObject err) pending_interrupt_p
(ThreadContext context, IRubyObject[] args) Deprecated.static IRubyObject
pending_interrupt_p
(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated.static IRubyObject
pending_interrupt_p_s
(ThreadContext context, IRubyObject self) static IRubyObject
pending_interrupt_p_s
(ThreadContext context, IRubyObject self, IRubyObject err) void
void
pollThreadEvents
(ThreadContext context) void
pollThreadEvents
(ThreadContext context, boolean blocking) Poll for thread events (raise, kill), propagating only events that are unmasked (seehandle_interrupt(ThreadContext, IRubyObject, IRubyObject, Block)
or intended to fire before blocking operations if blocking = true.static IRubyObject
prepareRaiseException
(ThreadContext context, IRubyObject[] args) protected void
priority()
Deprecated.priority
(ThreadContext context) priority_set
(IRubyObject priority) Deprecated.priority_set
(ThreadContext context, IRubyObject priority) final IRubyObject
raise
(IRubyObject exception) Simplified utility method for just raising an existing exception in this thread.final IRubyObject
raise
(IRubyObject exception, RubyString message) Simplified utility method for just raising an existing exception in this thread.raise
(ThreadContext context, IRubyObject[] args, Block block) report_on_exception
(ThreadContext context) static IRubyObject
report_on_exception
(ThreadContext context, IRubyObject self) report_on_exception_set
(ThreadContext context, IRubyObject state) static IRubyObject
report_on_exception_set
(ThreadContext context, IRubyObject self, IRubyObject state) static int
rubyPriorityToJavaPriority
(int rubyPriority) run()
boolean
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations.boolean
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.boolean
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations.boolean
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.boolean
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.boolean
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.set_trace_func
(ThreadContext context, IRubyObject trace_func, Block block) void
setAbortOnException
(boolean abortOnException) void
setContext
(ThreadContext context) setErrorInfo
(IRubyObject errorInfo) void
setFiberCurrentThread
(RubyThread fiberCurrentThread) setFiberScheduler
(IRubyObject scheduler) Deprecated.setFiberScheduler
(ThreadContext context, IRubyObject scheduler) Set the scheduler for the current thread.void
Set the pending interrupt flag.setName
(IRubyObject name) Deprecated.setName
(ThreadContext context, IRubyObject name) void
setReportOnException
(boolean reportOnException) boolean
sleep
(long milliseconds) Sleep the current thread for milliseconds, waking up on any thread interrupts.boolean
sleep
(long milliseconds, long nanoseconds) Sleep the current thread for milliseconds + nanoseconds, waking up on any thread interrupts.void
Release lock and sleep.void
Release lock and sleep for the specified number of milliseconds.static RubyThread
start
(IRubyObject recv, IRubyObject[] args, Block block) Deprecated.static RubyThread
start
(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Basically the same as Thread.new .protected static RubyThread
startWaiterThread
(Ruby runtime, long pid, Block block) status()
status
(ThreadContext context) static IRubyObject
stop
(ThreadContext context, IRubyObject receiver) stop_p()
Deprecated.stop_p
(ThreadContext context) thread_variable_get
(ThreadContext context, IRubyObject key) thread_variable_p
(ThreadContext context, IRubyObject key) thread_variable_set
(ThreadContext context, IRubyObject key, IRubyObject value) thread_variables
(ThreadContext context) <T> T
Customized for retrieving a Java thread from a Ruby one.toString()
The default toString method is just a wrapper that calls the Ruby "to_s" method.boolean
Try to acquire the given lock, adding it to a list of held locks for cleanup on thread termination if it is acquired.static <StateType>
IRubyObjectuninterruptible
(ThreadContext context, StateType state, BiFunction<ThreadContext, StateType, IRubyObject> f) Run the providedBiFunction
without allowing for any cross-thread interrupts (equivalent to callinghandle_interrupt(ThreadContext, IRubyObject, IRubyObject, Block)
with Object => :never.void
Release the given lock and remove it from the list of locks to be released on thread termination.void
Release all locks held.value()
Deprecated.value
(ThreadContext context) boolean
wait_timeout
(IRubyObject o, Double timeout) boolean
waitForIO
(ThreadContext context, RubyIO io, int ops) wakeup()
Methods inherited from class org.jruby.RubyObject
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, callInit, convertToType, dig, dig1, dig2, eqlInternal, equalInternal, finishObjectClass, getNativeClassIndex, inspect, op_eqq, puts, specificEval, toRubyString
Methods inherited from class org.jruby.RubyBasicObject
addFinalizer, addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkCallMethod, checkFrozen, checkStringType, cloneSetup, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, dataGetStruct, dataGetStructChecked, dataWrapStruct, decode, display, dup, dupFinalizer, dupSetup, ensureInstanceVariablesSettable, eql, eql_p, eql_p, equal_p, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, finishBasicObjectClass, forEachInstanceVariable, forEachInstanceVariableName, freeze, frozen_p, getCurrentContext, getFFIHandle, getFlag, getInstanceEvalClass, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMarshalVariableList, getMetaClass, getMetaClass, getNativeHandle, getNativeTypeIndex, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getSingletonClassCloneAndAttach, getSingletonClassCloneAndAttach, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hash, hashyInspect, hasInstanceVariable, hasInstanceVariables, hasInternalVariable, hasVariables, id, infectBy, initialize, initialize_copy, initialize_copy, inspect, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval, instance_exec, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isSpecialConst, isSpecialObject, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, makeMetaClass, makeMetaClassBootstrap, method, method, method, method_missing, methods, methods, nil_p, nonFixnumHashCode, nonFixnumHashCode, OBJ_INIT_COPY, objInitCopy, op_cmp, op_equal, op_match, op_not, op_not_equal, op_not_match, private_methods, protected_methods, public_methods, rbClone, rbClone, rbInspect, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, setFFIHandle, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setNativeHandle, setTaint, setUntrusted, setVariable, singleton_method, singleton_method, singleton_method_added, singleton_method_removed, singleton_method_undefined, singleton_methods, singletonClass, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_a, to_s, to_s, trust, type, untaint, untrust, untrusted_p, validateInstanceVariable, validateInstanceVariable, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.jruby.runtime.builtin.IRubyObject
checkStringType19, dup, marshalLiveVariables
-
Field Details
-
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:
-
-
Constructor Details
-
RubyThread
-
RubyThread
-
-
Method Details
-
getErrorInfo
-
setErrorInfo
-
setContext
-
clearContext
public void clearContext() -
getContext
-
getNativeThread
-
setFiberCurrentThread
-
getFiberCurrentThread
-
beforeStart
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. -
dispose
public void dispose()Dispose of the current thread by tidying up connections to other stuff -
createThreadClass
-
newInstance
Thread.new
Thread.new( [ arg ]* ) {| args | block }$ -> aThread
Creates a new thread to execute the instructions given in block, and begins running it. Any arguments passed to Thread.new are passed into the block.
x = Thread.new { sleep .1; print "x"; print "y"; print "z" } a = Thread.new { print "a"; print "b"; sleep .2; print "c" } x.join # Let the threads finish before a.join # main thread exits...
produces: abxyzc -
start
@Deprecated(since="10.0") public static RubyThread start(IRubyObject recv, IRubyObject[] args, Block block) Deprecated. -
start
public static RubyThread start(ThreadContext context, IRubyObject recv, IRubyObject[] args, Block block) Basically the same as Thread.new . However, if class Thread is subclassed, then calling start in that subclass will not invoke the subclass's initialize method. -
adopt
-
adopt
-
initialize
-
startWaiterThread
-
cleanTerminate
-
beDead
public void beDead() -
pollThreadEvents
public void pollThreadEvents() -
pollThreadEvents
Poll for thread events (raise, kill), propagating only events that are unmasked (seehandle_interrupt(ThreadContext, IRubyObject, IRubyObject, Block)
or intended to fire before blocking operations if blocking = true.- Parameters:
context
- the contextblocking
- whether to trigger blocking operation interrupts
-
pollThreadEvents
-
blockingThreadPoll
-
handle_interrupt
public static IRubyObject handle_interrupt(ThreadContext context, IRubyObject self, IRubyObject _mask, Block block) -
pending_interrupt_p_s
-
pending_interrupt_p_s
public static IRubyObject pending_interrupt_p_s(ThreadContext context, IRubyObject self, IRubyObject err) -
pending_interrupt_p
-
pending_interrupt_p
-
setName
Deprecated. -
setName
-
getName
Deprecated. -
getName
-
current
-
main
-
pass
-
list
-
add_trace_func
-
add_trace_func
public static IRubyObject add_trace_func(ThreadContext context, IRubyObject recv, IRubyObject trace_func, Block block) -
set_trace_func
-
clearFiberLocals
public void clearFiberLocals()Clear the fiber local variable storage for this thread. Meant for Java consumers when reusing threads (e.g. during thread pooling).- See Also:
-
clearThreadLocals
public void clearThreadLocals()Clear the thread local variable storage for this thread. Meant for Java consumers when reusing threads (e.g. during thread pooling).- See Also:
-
getContextVariables
- Specified by:
getContextVariables
in interfaceExecutionContext
-
isAlive
public boolean isAlive() -
isAdopted
public boolean isAdopted() -
fetch
-
fetch
-
op_aref
-
op_aset
-
key_p
-
keys
-
thread_variable_p
-
thread_variable_get
-
thread_variable_set
-
thread_variables
-
isAbortOnException
public boolean isAbortOnException() -
setAbortOnException
public void setAbortOnException(boolean abortOnException) -
abort_on_exception
-
abort_on_exception_set
-
abort_on_exception
Returns the status of the global ``abort on exception'' condition. The default is false. When set to true, will cause all threads to abort (the process will exit(0)) if an exception is raised in any thread. See also Thread.abort_on_exception= . -
abort_on_exception_set
public static IRubyObject abort_on_exception_set(ThreadContext context, IRubyObject recv, IRubyObject value) -
alive_p
-
join
-
join
-
value
-
group
-
inspect
Description copied from class:RubyBasicObject
Returns a string containing a human-readable representation of obj. If not overridden, uses theto_s
method to generate the string. [ 1, 2, 3..4, 'five' ].inspect #=> "[1, 2, 3..4, \"five\"]" Time.new.inspect #=> "Wed Apr 09 08:54:39 CDT 2003"- Specified by:
inspect
in interfaceIRubyObject
- Overrides:
inspect
in classRubyBasicObject
-
stop
-
kill
-
exit
-
stop_p
-
stop_p
Deprecated. -
wakeup
-
priority
Deprecated. -
priority
-
priority_set
Deprecated. -
priority_set
-
javaPriorityToRubyPriority
public static int javaPriorityToRubyPriority(int javaPriority) -
rubyPriorityToJavaPriority
public static int rubyPriorityToJavaPriority(int rubyPriority) -
raise
Simplified utility method for just raising an existing exception in this thread.- Parameters:
exception
- the exception to raise- Returns:
- this thread
-
raise
Simplified utility method for just raising an existing exception in this thread.- Parameters:
exception
- the exception to raisemessage
- the message to use- Returns:
- this thread
-
raise
-
native_thread_id
-
prepareRaiseException
-
run
-
sleep
Sleep the current thread for milliseconds, waking up on any thread interrupts.- Parameters:
milliseconds
- Number of milliseconds to sleep. Zero sleeps forever.- Throws:
InterruptedException
-
sleep
Sleep the current thread for milliseconds + nanoseconds, waking up on any thread interrupts. We can never be sure if a wait will finish because of a Java "spurious wakeup". So if we explicitly wakeup and we wait less than requested amount we will return false. We will return true if we sleep right amount or less than right amount via spurious wakeup.- Parameters:
milliseconds
- Number of milliseconds to sleep. Combined with nanoseconds, zero sleeps forever.nanoseconds
- Number of nanoseconds to sleep. Combined with milliseconds, zero sleeps forever.- Throws:
InterruptedException
-
status
-
status
-
each_caller_location
public static IRubyObject each_caller_location(ThreadContext context, IRubyObject recv, Block block) -
getExitingException
- Returns:
- existing exception or null if terminated normally
-
executeBlockingTask
@Deprecated public void executeBlockingTask(RubyThread.BlockingTask task) throws InterruptedException Deprecated.- Throws:
InterruptedException
-
executeTaskBlocking
public <Data,Return> Return executeTaskBlocking(ThreadContext context, Data data, RubyThread.Task<Data, Return> task) throws InterruptedException- Throws:
InterruptedException
-
executeTask
public <Data,Return> Return executeTask(ThreadContext context, Data data, RubyThread.Task<Data, Return> task) throws InterruptedException- Throws:
InterruptedException
-
executeTaskBlocking
public <Data,Return> Return executeTaskBlocking(ThreadContext context, Data data, RubyThread.Status status, RubyThread.Task<Data, Return> task) throws InterruptedException- Throws:
InterruptedException
-
executeTask
public <Data,Return> Return executeTask(ThreadContext context, Data data, RubyThread.Status status, RubyThread.Task<Data, Return> task) throws InterruptedException- Throws:
InterruptedException
-
executeReadWrite
public <Data> int executeReadWrite(ThreadContext context, Data data, byte[] bytes, int start, int length, RubyThread.ReadWrite<Data> task) throws InterruptedException Execute an interruptible read or write operation with the given byte range and data object.- Type Parameters:
Data
- the type of the data object- Parameters:
context
- the current contextdata
- a data objectbytes
- the bytes to writestart
- start range of bytes to writelength
- length of bytes to writetask
- the write task- Returns:
- the number of bytes written
- Throws:
InterruptedException
-
executeReadWrite
public <Data> int executeReadWrite(ThreadContext context, Data data, ByteBuffer bytes, int start, int length, RubyThread.ReadWrite<Data> task) throws InterruptedException - Throws:
InterruptedException
-
executeRegexp
public <Data> int executeRegexp(ThreadContext context, org.joni.Matcher matcher, int start, int range, int option, RubyThread.RegexMatch task) throws InterruptedException Execute an interruptible regexp operation with the given function and bytess.- Type Parameters:
Data
-- Parameters:
context
-matcher
-start
-range
-option
-task
-- Returns:
- ""
- Throws:
InterruptedException
- when interrupted
-
enterSleep
public void enterSleep() -
exitSleep
public void exitSleep() -
kill
-
dieFromFinalizer
public void dieFromFinalizer()Used for finalizers that need to kill a Ruby thread. Finalizers run in a VM thread to which we do not want to attach a ThreadContext and within which we do not want to check for Ruby thread events. This mechanism goes directly to mail delivery, bypassing all Ruby Thread-related steps. -
backtrace
-
backtrace
-
backtrace
-
backtrace_locations
-
backtrace_locations
-
backtrace_locations
public IRubyObject backtrace_locations(ThreadContext context, IRubyObject level, IRubyObject length) -
isReportOnException
public boolean isReportOnException() -
setReportOnException
public void setReportOnException(boolean reportOnException) -
report_on_exception_set
-
report_on_exception
-
report_on_exception_set
public static IRubyObject report_on_exception_set(ThreadContext context, IRubyObject self, IRubyObject state) -
report_on_exception
-
javaBacktrace
-
exceptionRaised
-
printReportExceptionWarning
protected void printReportExceptionWarning() -
exceptionRaised
For handling all exceptions bubbling out of threads- Parameters:
throwable
-
-
mainThread
-
select
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.- Parameters:
io
- the RubyIO that contains the channel, for managing blocked threads list.ops
- the operations to wait for, fromSelectionKey
.- Returns:
- true if the IO's channel became ready for the requested operations, false if it was not selectable.
-
select
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.- Parameters:
io
- the RubyIO that contains the channel, for managing blocked threads list.ops
- the operations to wait for, fromSelectionKey
.timeout
- 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.- Returns:
- true if the IO's channel became ready for the requested operations, false if it timed out or was not selectable.
-
select
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations.- Parameters:
channel
- the channel to perform a select against. If this is not a selectable channel, then this method will just return true.fptr
- the fptr that contains the channel, for managing blocked threads list.ops
- the operations to wait for, fromSelectionKey
.- Returns:
- true if the channel became ready for the requested operations, false if it was not selectable.
-
select
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations.- Parameters:
channel
- the channel to perform a select against. If this is not a selectable channel, then this method will just return true.io
- the RubyIO that contains the channel, for managing blocked threads list.ops
- the operations to wait for, fromSelectionKey
.- Returns:
- true if the channel became ready for the requested operations, false if it was not selectable.
-
select
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.- Parameters:
channel
- the channel to perform a select against. If this is not a selectable channel, then this method will just return true.io
- the RubyIO that contains the channel, for managing blocked threads list.ops
- the operations to wait for, fromSelectionKey
.timeout
- 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.- Returns:
- true if the channel became ready for the requested operations, false if it timed out or was not selectable.
-
select
Perform an interruptible select operation on the given channel and fptr, waiting for the requested operations or the given timeout.- Parameters:
channel
- the channel to perform a select against. If this is not a selectable channel, then this method will just return true.fptr
- the fptr that contains the channel, for managing blocked threads list.ops
- the operations to wait for, fromSelectionKey
.timeout
- 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.- Returns:
- true if the channel became ready for the requested operations, false if it timed out or was not selectable.
-
interrupt
public void interrupt() -
setInterrupt
public void setInterrupt()Set the pending interrupt flag. CRuby: RB_VM_SET_INTERRUPT/ -
waitForIO
-
beforeBlockingCall
-
beforeBlockingCall
Deprecated. -
afterBlockingCall
public void afterBlockingCall() -
wait_timeout
- Throws:
InterruptedException
-
getThreadGroup
-
equals
Description copied from class:RubyObject
This override does not do a "checked" dispatch.- Overrides:
equals
in classRubyObject
- Parameters:
obj
- object to compare- Returns:
- true if equals
- See Also:
-
hashCode
public int hashCode()Description copied from class:RubyObject
This override does not do "checked" dispatch since Object usually has #hash defined.- Overrides:
hashCode
in classRubyObject
- Returns:
- the hash code
- See Also:
-
toString
Description copied from class:RubyObject
The default toString method is just a wrapper that calls the Ruby "to_s" method.- Overrides:
toString
in classRubyObject
- Returns:
- string representation
-
lock
Acquire the given lock, holding a reference to it for cleanup on thread termination.- Parameters:
lock
- the lock to acquire, released on thread termination
-
lockInterruptibly
Acquire the given lock interruptibly, holding a reference to it for cleanup on thread termination.- Parameters:
lock
- the lock to acquire, released on thread termination- Throws:
InterruptedException
- if the lock acquisition is interrupted
-
tryLock
Try to acquire the given lock, adding it to a list of held locks for cleanup on thread termination if it is acquired. Return immediately if the lock cannot be acquired.- Parameters:
lock
- the lock to acquire, released on thread termination
-
unlock
Release the given lock and remove it from the list of locks to be released on thread termination.- Parameters:
lock
- the lock to release and dereferences
-
unlockAll
public void unlockAll()Release all locks held. -
sleep
Release lock and sleep.- Throws:
InterruptedException
-
sleep
Release lock and sleep for the specified number of milliseconds.- Throws:
InterruptedException
-
toJava
Customized for retrieving a Java thread from a Ruby one.- Specified by:
toJava
in interfaceIRubyObject
- Overrides:
toJava
in classRubyBasicObject
- Type Parameters:
T
- type- Parameters:
target
- The target type to which the object should be converted (e.g.java.lang.Thread.class
).- Returns:
- java type
- Since:
- 9.4
- See Also:
-
uninterruptible
public static <StateType> IRubyObject uninterruptible(ThreadContext context, StateType state, BiFunction<ThreadContext, StateType, IRubyObject> f) Run the providedBiFunction
without allowing for any cross-thread interrupts (equivalent to callinghandle_interrupt(ThreadContext, IRubyObject, IRubyObject, Block)
with Object => :never. MRI: rb_uninterruptible- Parameters:
context
- the current contextf
- the bifunction to execute- Returns:
- return value of f.apply.
-
setFiberScheduler
Deprecated. -
setFiberScheduler
Set the scheduler for the current thread. MRI: rb_fiber_scheduler_set -
getScheduler
-
getSchedulerCurrent
-
incrementBlocking
public void incrementBlocking() -
decrementBlocking
public void decrementBlocking() -
isBlocking
public boolean isBlocking() -
pending_interrupt_p
Deprecated. -
pending_interrupt_p
@Deprecated public static IRubyObject pending_interrupt_p(ThreadContext context, IRubyObject self, IRubyObject[] args) Deprecated. -
alive_p
Deprecated. -
value
Deprecated. -
join
Deprecated. -
op_aset
Deprecated.
-