123456789_123456789_123456789_123456789_123456789_

Class: Pool

Relationships & Source Files
Super Chains via Extension / Inclusion / Inheritance
Class Chain:
self, ::Fiber
Instance Chain:
self, ::Fiber
Inherits: Fiber
Defined in: cont.c

Class Attribute Summary

::Fiber - Inherited

.blocking?

Returns false if the current fiber is non-blocking.

Class Method Summary

::Fiber - Inherited

.current

Returns the current fiber.

.new

Creates new ::Fiber.

.schedule

The method is expected to immediately run the provided block of code in a separate non-blocking fiber.

.scheduler

::Fiber scheduler, set in the current thread with Fiber.set_scheduler.

.set_scheduler

Sets Fiber scheduler for the current thread.

.yield

Yields control back to the context that resumed the fiber, passing along any arguments that were passed to it.

Instance Attribute Summary

::Fiber - Inherited

#alive?

Returns true if the fiber can still be resumed (or transferred to).

#blocking?

Returns true if fiber is blocking and false otherwise.

Instance Method Summary

::Fiber - Inherited

#backtrace

Returns the current execution stack of the fiber.

#backtrace_locations

Like #backtrace, but returns each line of the execution stack as a ::Thread::Backtrace::Location.

#inspect

Alias for Fiber#to_s.

#raise

Raises an exception in the fiber at the point at which the last Fiber.yield was called.

#resume

Resumes the fiber from the point at which the last Fiber.yield was called, or starts running it if it is the first call to #resume.

#to_s

Returns fiber information string.

#transfer

Transfer control to another fiber, resuming it from where it last stopped or starting it if it was not resumed before.

Constructor Details

.new(*args)

[ GitHub ]

  
# File 'cont.c', line 2815

static VALUE
rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self)
{
    rb_thread_t *th = GET_THREAD();
    VALUE size = Qnil, count = Qnil, vm_stack_size = Qnil;
    struct fiber_pool * fiber_pool = NULL;

    // Maybe these should be keyword arguments.
    rb_scan_args(argc, argv, "03", &size, &count, &vm_stack_size);

    if (NIL_P(size)) {
        size = INT2NUM(th->vm->default_params.fiber_machine_stack_size);
    }

    if (NIL_P(count)) {
        count = INT2NUM(128);
    }

    if (NIL_P(vm_stack_size)) {
        vm_stack_size = INT2NUM(th->vm->default_params.fiber_vm_stack_size);
    }

    TypedData_Get_Struct(self, struct fiber_pool, &FiberPoolDataType, fiber_pool);

    fiber_pool_initialize(fiber_pool, NUM2SIZET(size), NUM2SIZET(count), NUM2SIZET(vm_stack_size));

    return self;
}