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 Method Summary

::Fiber - Inherited

.current

Returns the current fiber.

.yield

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

.new

Instance Attribute Summary

::Fiber - Inherited

#alive?

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

Instance Method Summary

::Fiber - Inherited

#inspect

Alias for Fiber#to_s.

#raise

Raises an exception in the fiber at the point at which the last Fiber.yield was called, or at the start if neither resume nor raise were called before.

#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 2378

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;
}