public class RubyThread extends RubyObject implements ExecutionContext
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 |
---|---|
static interface |
RubyThread.BlockingTask |
static class |
RubyThread.SleepTask |
static class |
RubyThread.Status |
RubyObject.Data
RubyBasicObject.Finalizer
OBJECT_ALLOCATOR, REIFYING_OBJECT_ALLOCATOR
ALL_F, BASICOBJECT_ALLOCATOR, COMPARE_BY_IDENTITY_F, ERR_INSECURE_SET_INST_VAR, FALSE_F, FL_USHIFT, flags, FROZEN_F, metaClass, NEVER, NIL_F, TAINTED_F, UNDEF, UNTRUSTED_F, USER0_F, USER1_F, USER2_F, USER3_F, USER4_F, USER5_F, USER6_F, USER7_F, USER8_F
NULL_ARRAY
Modifier | Constructor and Description |
---|---|
protected |
RubyThread(Ruby runtime,
RubyClass type) |
Modifier and Type | Method and Description |
---|---|
static IRubyObject |
abort_on_exception_set_x(IRubyObject recv,
IRubyObject value) |
IRubyObject |
abort_on_exception_set(IRubyObject val) |
static RubyBoolean |
abort_on_exception_x(IRubyObject recv)
Returns the status of the global ``abort on exception'' condition.
|
RubyBoolean |
abort_on_exception() |
static RubyThread |
adopt(IRubyObject recv,
java.lang.Thread t) |
void |
afterBlockingCall() |
RubyBoolean |
alive_p() |
IRubyObject |
backtrace(ThreadContext context) |
void |
beDead() |
void |
beforeBlockingCall() |
void |
checkMail(ThreadContext context) |
void |
cleanTerminate(IRubyObject result) |
static RubyClass |
createThreadClass(Ruby runtime) |
static IRubyObject |
critical_set(IRubyObject receiver,
IRubyObject value) |
static IRubyObject |
critical(IRubyObject receiver) |
static RubyThread |
current(IRubyObject recv) |
void |
dispose()
Dispose of the current thread by removing it from its parent ThreadGroup.
|
void |
enterSleep() |
boolean |
equals(java.lang.Object obj)
This method is just a wrapper around the Ruby "==" method,
provided so that RubyObjects can be used as keys in the Java
HashMap object underlying RubyHash.
|
void |
exceptionRaised(RaiseException exception) |
void |
executeBlockingTask(RubyThread.BlockingTask task) |
void |
exitSleep() |
ThreadContext |
getContext() |
java.util.Map<java.lang.Object,IRubyObject> |
getContextVariables() |
IRubyObject |
getErrorInfo() |
java.lang.Thread |
getNativeThread() |
IRubyObject |
group() |
int |
hashCode()
Override the Object#hashCode method to make sure that the Ruby
hash is actually used as the hashcode for Ruby objects.
|
IRubyObject |
initialize(ThreadContext context,
IRubyObject[] args,
Block block) |
IRubyObject |
inspect()
rb_obj_inspect
call-seq:
obj.inspect => string
Returns a string containing a human-readable representation of
obj.
|
void |
internalRaise(IRubyObject[] args)
This is intended to be used to raise exceptions in Ruby threads from non-
Ruby threads like Timeout's thread.
|
void |
interrupt() |
boolean |
isAlive() |
java.lang.StackTraceElement[] |
javaBacktrace() |
IRubyObject |
join(IRubyObject[] args) |
RubyBoolean |
key_p(IRubyObject key) |
RubyArray |
keys() |
IRubyObject |
kill_bang() |
IRubyObject |
kill() |
static IRubyObject |
kill(IRubyObject receiver,
IRubyObject rubyThread,
Block block) |
static RubyArray |
list(IRubyObject recv) |
static RubyThread |
main(IRubyObject recv) |
static RubyThread |
mainThread(IRubyObject receiver) |
static IRubyObject |
newInstance(IRubyObject recv,
IRubyObject[] args,
Block block)
Thread.new |
IRubyObject |
op_aref(IRubyObject key) |
IRubyObject |
op_aset(IRubyObject key,
IRubyObject value) |
static IRubyObject |
pass(IRubyObject recv) |
void |
pollThreadEvents() |
void |
pollThreadEvents(ThreadContext context) |
IRubyObject |
priority_set(IRubyObject priority) |
RubyFixnum |
priority() |
IRubyObject |
raise(IRubyObject[] args,
Block block) |
void |
receiveMail(ThreadService.Event event) |
IRubyObject |
run() |
static IRubyObject |
s_exit(IRubyObject receiver,
Block block) |
IRubyObject |
safe_level() |
boolean |
select(java.nio.channels.Channel channel,
RubyIO io,
int ops) |
boolean |
select(java.nio.channels.Channel channel,
RubyIO io,
int ops,
long timeout) |
boolean |
select(RubyIO io,
int ops) |
boolean |
select(RubyIO io,
int ops,
long timeout) |
boolean |
selectForAccept(RubyIO io)
Deprecated.
|
void |
setContext(ThreadContext context) |
IRubyObject |
setErrorInfo(IRubyObject errorInfo) |
boolean |
sleep(long millis)
We can never be sure if a wait will finish because of a Java "spurious wakeup".
|
static RubyThread |
start(IRubyObject recv,
IRubyObject[] args,
Block block)
Basically the same as Thread.new .
|
IRubyObject |
status() |
RubyBoolean |
stop_p() |
static IRubyObject |
stop(ThreadContext context,
IRubyObject receiver) |
java.lang.String |
toString()
The default toString method is just a wrapper that calls the
Ruby "to_s" method.
|
IRubyObject |
value() |
boolean |
wait_timeout(IRubyObject o,
java.lang.Double timeout) |
boolean |
waitForIO(ThreadContext context,
RubyIO io,
int ops) |
RubyThread |
wakeup() |
attachToObjectSpace, callInit, callInit, callInit, callInit, callInit, convertToType, createObjectClass, eqlInternal, equalInternal, getNativeTypeIndex, initialize, op_eqq, puts, specificEval
addFinalizer, anyToString, asJavaString, asString, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callMethod, callSuper, checkArrayType, checkCallMethod, checkFrozen, checkStringType, checkStringType19, compareTo, convertToArray, convertToFloat, convertToHash, convertToInteger, convertToInteger, convertToInteger, convertToString, copyInstanceVariablesInto, copySpecialInstanceVariables, createBasicObjectClass, dataGetStruct, dataGetStructChecked, dataWrapStruct, display, dup, ensureInstanceVariablesSettable, eql_p, eql, equal_p, equal_p19, evalUnder, extend, fastGetInstanceVariable, fastGetInternalVariable, fastHasInstanceVariable, fastHasInternalVariable, fastSetInstanceVariable, fastSetInternalVariable, freeze, frozen_p, getFlag, getInstanceEvalClass, getInstanceVariable, getInstanceVariableList, getInstanceVariableNameList, getInstanceVariables, getInternalVariable, getInternalVariables, getJavaClass, getMetaClass, getObjectId, getRuntime, getSingletonClass, getSingletonClassClone, getType, getVariable, getVariableCount, getVariableList, getVariableNameList, hash, hashyInspect, hasInstanceVariable, hasInternalVariable, hasVariables, id_deprecated, id, infectBy, initialize_copy, initialize19, initialize19, initialize19, initialize19, initialize19, initObjectId, inspectHashCode, instance_eval, instance_eval, instance_eval, instance_eval, instance_eval19, instance_eval19, instance_eval19, instance_eval19, instance_exec, instance_exec19, instance_of_p, instance_variable_defined_p, instance_variable_get, instance_variable_set, instance_variables, instance_variables19, isBuiltin, isClass, isFalse, isFrozen, isImmediate, isModule, isNil, isTaint, isTrue, isUntrusted, kind_of_p, makeMetaClass, method_missing19, method, method19, methods, methods, methods19, nil_p, op_cmp, op_equal_19, op_equal, op_match, op_match19, op_not_equal, op_not_match, op_not, private_methods, private_methods19, protected_methods, protected_methods19, public_methods, public_methods19, rbClone, remove_instance_variable, removeFinalizers, removeInstanceVariable, removeInternalVariable, respond_to_p, respond_to_p, respond_to_p19, respond_to_p19, respondsTo, respondsToMissing, respondsToMissing, send, send, send, send, send, send19, send19, send19, send19, send19, setFlag, setFrozen, setInstanceVariable, setInternalVariable, setMetaClass, setTaint, setUntrusted, setVariable, singleton_method_added19, singleton_method_removed19, singleton_method_undefined19, singleton_methods, singleton_methods19, specificEval, specificEval, specificEval, specificEval, syncVariables, syncVariables, taint, taint, tainted_p, testFrozen, testFrozen, to_a, to_s, toJava, trust, type_deprecated, type, untaint, untrust, untrusted_p, validateInstanceVariable, variableTableContains, variableTableFastContains, variableTableFastFetch, variableTableFastStore, variableTableFetch, variableTableRemove, variableTableStore, variableTableSync, yieldUnder, yieldUnder
public void receiveMail(ThreadService.Event event)
public void checkMail(ThreadContext context)
public IRubyObject getErrorInfo()
public IRubyObject setErrorInfo(IRubyObject errorInfo)
public void setContext(ThreadContext context)
public ThreadContext getContext()
public java.lang.Thread getNativeThread()
public void dispose()
public static IRubyObject newInstance(IRubyObject recv, IRubyObject[] args, Block block)
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
public static RubyThread start(IRubyObject recv, IRubyObject[] args, Block block)
public static RubyThread adopt(IRubyObject recv, java.lang.Thread t)
public IRubyObject initialize(ThreadContext context, IRubyObject[] args, Block block)
public void cleanTerminate(IRubyObject result)
public void beDead()
public void pollThreadEvents()
public void pollThreadEvents(ThreadContext context)
public static RubyBoolean abort_on_exception_x(IRubyObject recv)
public static IRubyObject abort_on_exception_set_x(IRubyObject recv, IRubyObject value)
public static RubyThread current(IRubyObject recv)
public static RubyThread main(IRubyObject recv)
public static IRubyObject pass(IRubyObject recv)
public static RubyArray list(IRubyObject recv)
public final java.util.Map<java.lang.Object,IRubyObject> getContextVariables()
getContextVariables
in interface ExecutionContext
public boolean isAlive()
public IRubyObject op_aref(IRubyObject key)
public IRubyObject op_aset(IRubyObject key, IRubyObject value)
public RubyBoolean abort_on_exception()
public IRubyObject abort_on_exception_set(IRubyObject val)
public RubyBoolean alive_p()
public IRubyObject join(IRubyObject[] args)
public IRubyObject value()
public IRubyObject group()
public IRubyObject inspect()
RubyBasicObject
to_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"inspect
in interface IRubyObject
inspect
in class RubyBasicObject
public RubyBoolean key_p(IRubyObject key)
public RubyArray keys()
public static IRubyObject critical_set(IRubyObject receiver, IRubyObject value)
public static IRubyObject critical(IRubyObject receiver)
public static IRubyObject stop(ThreadContext context, IRubyObject receiver)
public static IRubyObject kill(IRubyObject receiver, IRubyObject rubyThread, Block block)
public static IRubyObject s_exit(IRubyObject receiver, Block block)
public RubyBoolean stop_p()
public RubyThread wakeup()
public RubyFixnum priority()
public IRubyObject priority_set(IRubyObject priority)
public IRubyObject raise(IRubyObject[] args, Block block)
public void internalRaise(IRubyObject[] args)
args
- Same args as for Thread#raiseblock
- Same as for Thread#raisepublic IRubyObject run()
public boolean sleep(long millis) throws java.lang.InterruptedException
java.lang.InterruptedException
public IRubyObject status()
public void executeBlockingTask(RubyThread.BlockingTask task) throws java.lang.InterruptedException
java.lang.InterruptedException
public void enterSleep()
public void exitSleep()
public IRubyObject kill()
public IRubyObject kill_bang()
public IRubyObject safe_level()
public IRubyObject backtrace(ThreadContext context)
public java.lang.StackTraceElement[] javaBacktrace()
public void exceptionRaised(RaiseException exception)
public static RubyThread mainThread(IRubyObject receiver)
@Deprecated public boolean selectForAccept(RubyIO io)
public boolean select(RubyIO io, int ops)
public boolean select(RubyIO io, int ops, long timeout)
public boolean select(java.nio.channels.Channel channel, RubyIO io, int ops)
public boolean select(java.nio.channels.Channel channel, RubyIO io, int ops, long timeout)
public void interrupt()
public boolean waitForIO(ThreadContext context, RubyIO io, int ops)
public void beforeBlockingCall()
public void afterBlockingCall()
public boolean wait_timeout(IRubyObject o, java.lang.Double timeout) throws java.lang.InterruptedException
java.lang.InterruptedException
public boolean equals(java.lang.Object obj)
RubyObject
equals
in class RubyObject
public int hashCode()
RubyObject
hashCode
in class RubyObject
public java.lang.String toString()
RubyObject
toString
in class RubyObject
Copyright © 2002-2009 JRuby Team. All Rights Reserved.