Class: Pool

Inherits:
Fiber show all
Defined in:
cont.c

Instance Method Summary collapse

Methods inherited from Fiber

#alive?, current, #raise, #resume, #to_s, #transfer, yield

Constructor Details

#initialize(*args) ⇒ Object



2369
2370
2371
2372
2373
2374
2375
2376
2377
2378
2379
2380
2381
2382
2383
2384
2385
2386
2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
# File 'cont.c', line 2369

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