Top Inners Fields Constructors Methods
org.jruby.ext.fiber

public Class ThreadFiber

extends RubyObject
implements ExecutionContext
Class Inheritance
All Implemented Interfaces
org.jruby.runtime.ExecutionContext
Imports
org.jruby.Ruby, .RubyArray, .RubyBasicObject, .RubyClass, .RubyException, .RubyFixnum, .RubyHash, .RubyKernel, .RubyObject, .RubySymbol, .RubyThread, org.jruby.anno.JRubyMethod, org.jruby.ast.util.ArgsUtil, org.jruby.exceptions.FiberKill, .JumpException, .RaiseException, org.jruby.ir.operands.IRException, org.jruby.ir.runtime.IRBreakJump, .IRReturnJump, org.jruby.javasupport.JavaUtil, org.jruby.runtime.Block, .ExecutionContext, .Helpers, .ThreadContext, .Visibility, org.jruby.runtime.builtin.IRubyObject, org.jruby.util.cli.Options, org.jruby.util.log.Logger, .LoggerFactory, java.lang.invoke.MethodHandle, .MethodHandles, java.lang.ref.WeakReference, java.lang.reflect.Method, java.util.Map, java.util.concurrent.atomic.AtomicReference, java.util.function.BiConsumer

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
public static class
public static enum
private static class

Field Summary

Modifier and TypeField and Description
pack-priv volatile ThreadFiber.FiberData
private static final BiConsumer<Ruby, Runnable>
private static final String[]
private static final Logger
private static final ThreadFiber.FiberRequest
pack-priv final boolean
pack-priv RubyHash
pack-priv volatile RubyThread
private static final MethodHandle
Inherited from org.jruby.RubyObject:
IVAR_INSPECTING_OBJECT_ALLOCATOROBJECT_ALLOCATORREIFYING_OBJECT_ALLOCATOR

Constructor Summary

AccessConstructor and Description
public
ThreadFiber(Ruby runtime, RubyClass klass)

public
ThreadFiber(Ruby runtime, RubyClass klass, boolean root)

Method Summary

Modifier and TypeMethod and Description
public IRubyObject
private static void
adjustThreadBlocking(ThreadContext context, ThreadFiber.FiberData currentFiberData, ThreadFiber.FiberData targetFiberData)

pack-priv final boolean
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public IRubyObject
public static IRubyObject
blocking(ThreadContext context, IRubyObject self, Block block)

public IRubyObject
public static IRubyObject
private void
pack-priv static RubyThread
createThread(ThreadContext context, final ThreadFiber.FiberData data, final FiberQueue queue, final Block block)

public static IRubyObject
private void
private static ThreadFiber.FiberRequest
private static void
protected void
finalize()

Overrides java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

public Map<Object, IRubyObject>
public ThreadFiber.FiberData
public RubyThread
private static void
handleExceptionDuringExchange(ThreadContext context, ThreadFiber.FiberData currentFiberData, ThreadFiber.FiberData targetFiberData, RaiseException re)

Handle exceptions raised while exchanging data with a fiber.

public void
public IRubyObject
initialize(ThreadContext context, Block block)

public IRubyObject
initialize(ThreadContext context, IRubyObject _opts, Block block)

public static void
initRootFiber(ThreadContext context, RubyThread currentThread)

public boolean
public IRubyObject
private static void
nativeThreadLauncher(Ruby runtime, Runnable runnable)

public static IRubyObject
public static IRubyObject
private static IRubyObject
public IRubyObject
raise(ThreadContext context, IRubyObject[] args)

public IRubyObject
raise(ThreadContext context, IRubyObject exception)

public IRubyObject
resume(ThreadContext context, IRubyObject[] values)

private void
public IRubyObject
public IRubyObject
public IRubyObject
transfer(ThreadContext context, IRubyObject[] values)

private static void
private static ThreadFiber.FiberData
public static IRubyObject
public static IRubyObject
public static IRubyObject
yield(ThreadContext context, IRubyObject recv, IRubyObject[] value)

Inherited from org.jruby.RubyObject:
attachToObjectSpacecallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitcallInitconvertToTypedigdig1dig2eqlInternalequalInternalequalsfinishObjectClassgetNativeClassIndexhashCodeinspectop_eqqputsspecificEvaltoRubyStringtoString

Field Detail

databack to summary
pack-priv volatile ThreadFiber.FiberData data
FIBER_LAUNCHERback to summary
private static final BiConsumer<Ruby, Runnable> FIBER_LAUNCHER
INITIALIZE_KWARGSback to summary
private static final String[] INITIALIZE_KWARGS
LOGback to summary
private static final Logger LOG
NEVERback to summary
private static final ThreadFiber.FiberRequest NEVER

Hides org.jruby.RubyBasicObject.NEVER.

rootback to summary
pack-priv final boolean root
storageback to summary
pack-priv RubyHash storage
threadback to summary
pack-priv volatile RubyThread thread
VTHREAD_START_METHODback to summary
private static final MethodHandle VTHREAD_START_METHOD

Constructor Detail

ThreadFiberback to summary
public ThreadFiber(Ruby runtime, RubyClass klass)
ThreadFiberback to summary
public ThreadFiber(Ruby runtime, RubyClass klass, boolean root)

Method Detail

__finalize__back to summary
public IRubyObject __finalize__(ThreadContext context)
Annotations
@JRubyMethod
visibility:PRIVATE
adjustThreadBlockingback to summary
private static void adjustThreadBlocking(ThreadContext context, ThreadFiber.FiberData currentFiberData, ThreadFiber.FiberData targetFiberData)
aliveback to summary
pack-priv final boolean alive()
alive_pback to summary
public IRubyObject alive_p(ThreadContext context)
Annotations
@JRubyMethod
name:alive?
backtraceback to summary
public IRubyObject backtrace(ThreadContext context)
Annotations
@JRubyMethod
name:backtrace
backtraceback to summary
public IRubyObject backtrace(ThreadContext context, IRubyObject level)
Annotations
@JRubyMethod
name:backtrace
backtraceback to summary
public IRubyObject backtrace(ThreadContext context, IRubyObject level, IRubyObject length)
Annotations
@JRubyMethod
name:backtrace
backtrace_locationsback to summary
public IRubyObject backtrace_locations(ThreadContext context)
Annotations
@JRubyMethod
name:backtrace_locations
backtrace_locationsback to summary
public IRubyObject backtrace_locations(ThreadContext context, IRubyObject level)
Annotations
@JRubyMethod
name:backtrace_locations
backtrace_locationsback to summary
public IRubyObject backtrace_locations(ThreadContext context, IRubyObject level, IRubyObject length)
Annotations
@JRubyMethod
name:backtrace_locations
blockingback to summary
public static IRubyObject blocking(ThreadContext context, IRubyObject self, Block block)
Annotations
@JRubyMethod
name:blocking
meta:true
blocking_pback to summary
public IRubyObject blocking_p(ThreadContext context)
Annotations
@JRubyMethod
name:blocking?
blocking_p_sback to summary
public static IRubyObject blocking_p_s(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
name:blocking?
meta:true
checkSameFiberback to summary
private void checkSameFiber(ThreadContext context)
createThreadback to summary
pack-priv static RubyThread createThread(ThreadContext context, final ThreadFiber.FiberData data, final FiberQueue queue, final Block block)
currentback to summary
public static IRubyObject current(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
meta:true
doFinalizeback to summary
private void doFinalize()
exchangeWithFiberback to summary
private static ThreadFiber.FiberRequest exchangeWithFiber(ThreadContext context, ThreadFiber.FiberData currentFiberData, ThreadFiber.FiberData targetFiberData, ThreadFiber.FiberRequest request)
fiberCalledAcrossThreadsback to summary
private static void fiberCalledAcrossThreads(Ruby runtime)
finalizeback to summary
protected void finalize() throws Throwable

Overrides java.lang.Object.finalize.

Doc from java.lang.Object.finalize.

Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. A subclass overrides the finalize method to dispose of system resources or to perform other cleanup.

When running in a Java virtual machine in which finalization has been disabled or removed, the garbage collector will never call finalize(). In a Java virtual machine in which finalization is enabled, the garbage collector might call finalize only after an indefinite delay.

The general contract of finalize is that it is invoked if and when the Java virtual machine has determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, except as a result of an action taken by the finalization of some other object or class which is ready to be finalized. The finalize method may take any action, including making this object available again to other threads; the usual purpose of finalize, however, is to perform cleanup actions before the object is irrevocably discarded. For example, the finalize method for an object that represents an input/output connection might perform explicit I/O transactions to break the connection before the object is permanently discarded.

The finalize method of class Object performs no special action; it simply returns normally. Subclasses of Object may override this definition.

The Java programming language does not guarantee which thread will invoke the finalize method for any given object. It is guaranteed, however, that the thread that invokes finalize will not be holding any user-visible synchronization locks when finalize is invoked. If an uncaught exception is thrown by the finalize method, the exception is ignored and finalization of that object terminates.

After the finalize method has been invoked for an object, no further action is taken until the Java virtual machine has again determined that there is no longer any means by which this object can be accessed by any thread that has not yet died, including possible actions by other objects or classes which are ready to be finalized, at which point the object may be discarded.

The finalize method is never invoked more than once by a Java virtual machine for any given object.

Any exception thrown by the finalize method causes the finalization of this object to be halted, but is otherwise ignored.

Annotations
@Override
Exceptions
Throwable:
the Exception raised by this method
getContextVariablesback to summary
public Map<Object, IRubyObject> getContextVariables()

Implements org.jruby.runtime.ExecutionContext.getContextVariables.

Annotations
@Override
getDataback to summary
public ThreadFiber.FiberData getData()
getThreadback to summary
public RubyThread getThread()
handleExceptionDuringExchangeback to summary
private static void handleExceptionDuringExchange(ThreadContext context, ThreadFiber.FiberData currentFiberData, ThreadFiber.FiberData targetFiberData, RaiseException re)

Handle exceptions raised while exchanging data with a fiber. The rules work like this:

  • If the thread has called Fiber#resume on the fiber and an interrupt is sent to the thread, forward it to the fiber
  • If the fiber has called Fiber.yield and an interrupt is sent to the fiber (e.g. Timeout.timeout(x) { Fiber.yield }) forward it to the fiber's parent thread.
inheritFiberStorageback to summary
public void inheritFiberStorage(ThreadContext context)
initializeback to summary
public IRubyObject initialize(ThreadContext context, Block block)
Annotations
@JRubyMethod
visibility:PRIVATE
initializeback to summary
public IRubyObject initialize(ThreadContext context, IRubyObject _opts, Block block)
Annotations
@JRubyMethod
visibility:PRIVATE
initRootFiberback to summary
public static void initRootFiber(ThreadContext context, RubyThread currentThread)
isBlockingback to summary
public boolean isBlocking()
killback to summary
public IRubyObject kill(ThreadContext context)
Annotations
@JRubyMethod
nativeThreadLauncherback to summary
private static void nativeThreadLauncher(Ruby runtime, Runnable runnable)
op_arefback to summary
public static IRubyObject op_aref(ThreadContext context, IRubyObject recv, IRubyObject key)
Annotations
@JRubyMethod
name:[]
meta:true
op_asetback to summary
public static IRubyObject op_aset(ThreadContext context, IRubyObject recv, IRubyObject key, IRubyObject value)
Annotations
@JRubyMethod
name:[]=
meta:true
processResultDataback to summary
private static IRubyObject processResultData(ThreadContext context, ThreadFiber.FiberRequest result)
raiseback to summary
public IRubyObject raise(ThreadContext context, IRubyObject[] args)
Annotations
@JRubyMethod
rest:true
raiseback to summary
public IRubyObject raise(ThreadContext context, IRubyObject exception)
resumeback to summary
public IRubyObject resume(ThreadContext context, IRubyObject[] values)
Annotations
@JRubyMethod
rest:true
keywords:true
setStorageback to summary
private void setStorage(ThreadContext context, IRubyObject hash)
storageback to summary
public IRubyObject storage(ThreadContext context)
Annotations
@JRubyMethod
storage_setback to summary
public IRubyObject storage_set(ThreadContext context, IRubyObject hash)
Annotations
@JRubyMethod
name:storage=
transferback to summary
public IRubyObject transfer(ThreadContext context, IRubyObject[] values)
Annotations
@JRubyMethod
rest:true
validateStorageback to summary
private static void validateStorage(ThreadContext context, IRubyObject hashArg)
verifyCurrentFiberback to summary
private static ThreadFiber.FiberData verifyCurrentFiber(ThreadContext context, Ruby runtime)
yieldback to summary
public static IRubyObject yield(ThreadContext context, IRubyObject recv)
Annotations
@JRubyMethod
meta:true
yieldback to summary
public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject value)
Annotations
@JRubyMethod
meta:true
yieldback to summary
public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject[] value)
Annotations
@JRubyMethod
meta:true
rest:true
org.jruby.ext.fiber back to summary

public Class ThreadFiber.FiberData

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv volatile boolean
pack-priv final WeakReference<ThreadFiber>
pack-priv final RubyThread
pack-priv volatile ThreadFiber
pack-priv final FiberQueue
pack-priv volatile boolean

Constructor Summary

AccessConstructor and Description
pack-priv
FiberData(FiberQueue queue, RubyThread parent, ThreadFiber fiber, boolean blocking)

Method Summary

Modifier and TypeMethod and Description
public ThreadFiber
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

blockingback to summary
pack-priv volatile boolean blocking
fiberback to summary
pack-priv final WeakReference<ThreadFiber> fiber
parentback to summary
pack-priv final RubyThread parent
prevback to summary
pack-priv volatile ThreadFiber prev
queueback to summary
pack-priv final FiberQueue queue
transferredback to summary
pack-priv volatile boolean transferred

Constructor Detail

FiberDataback to summary
pack-priv FiberData(FiberQueue queue, RubyThread parent, ThreadFiber fiber, boolean blocking)

Method Detail

getPrevback to summary
public ThreadFiber getPrev()
org.jruby.ext.fiber back to summary

public Class ThreadFiber.FiberRequest

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
pack-priv final Object
pack-priv final ThreadFiber.RequestType

Constructor Summary

AccessConstructor and Description
pack-priv

Method Summary

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

databack to summary
pack-priv final Object data
typeback to summary
pack-priv final ThreadFiber.RequestType type

Constructor Detail

FiberRequestback to summary
pack-priv FiberRequest(Object data, ThreadFiber.RequestType type)
org.jruby.ext.fiber back to summary

public Class ThreadFiber.FiberSchedulerSupport

extends Object
Class Inheritance

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public static IRubyObject
public static IRubyObject
public static IRubyObject
schedule(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block)

public static IRubyObject
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

FiberSchedulerSupportback to summary
public FiberSchedulerSupport()

Method Detail

current_schedulerback to summary
public static IRubyObject current_scheduler(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
name:current_scheduler
meta:true
get_schedulerback to summary
public static IRubyObject get_scheduler(ThreadContext context, IRubyObject self)
Annotations
@JRubyMethod
name:scheduler
meta:true
scheduleback to summary
public static IRubyObject schedule(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block)
Annotations
@JRubyMethod
name:schedule
meta:true
rest:true
keywords:true
set_schedulerback to summary
public static IRubyObject set_scheduler(ThreadContext context, IRubyObject self, IRubyObject scheduler)
Annotations
@JRubyMethod
name:set_scheduler
meta:true
org.jruby.ext.fiber back to summary

public final Enum ThreadFiber.RequestType

extends Enum<ThreadFiber.RequestType>
Class Inheritance

Field Summary

Modifier and TypeField and Description
public static final ThreadFiber.RequestType
public static final ThreadFiber.RequestType

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ThreadFiber.RequestType
public static ThreadFiber.RequestType[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

DATAback to summary
public static final ThreadFiber.RequestType DATA
RAISEback to summary
public static final ThreadFiber.RequestType RAISE

Constructor Detail

RequestTypeback to summary
private RequestType()

Method Detail

valueOfback to summary
public static ThreadFiber.RequestType valueOf(String name)
valuesback to summary
public static ThreadFiber.RequestType[] values()
org.jruby.ext.fiber back to summary

private Class ThreadFiber.VirtualThreadLauncher

extends Object
implements BiConsumer<Ruby, Runnable>
Class Inheritance
All Implemented Interfaces
java.util.function.BiConsumer

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public void
accept(Ruby
the first input argument
ruby
,
Runnable
the second input argument
runnable
)

Implements java.util.function.BiConsumer.accept.

Performs this operation on the given arguments.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

VirtualThreadLauncherback to summary
private VirtualThreadLauncher()

Method Detail

acceptback to summary
public void accept(Ruby ruby, Runnable runnable)

Implements java.util.function.BiConsumer.accept.

Doc from java.util.function.BiConsumer.accept.

Performs this operation on the given arguments.

Parameters
ruby:Ruby

the first input argument

runnable:Runnable

the second input argument

Annotations
@Override