Example #1
0
static VALUE
next_i(VALUE curr, VALUE obj)
{
    struct enumerator *e = enumerator_ptr(obj);
    VALUE nil = Qnil;

    rb_block_call(obj, rb_intern("each"), 0, 0, next_ii, obj);
    e->no_next = Qtrue;
    return rb_fiber_yield(1, &nil);
}
Example #2
0
static VALUE
next_i(VALUE curr, VALUE obj)
{
    struct enumerator *e = enumerator_ptr(obj);
    VALUE nil = Qnil;
    VALUE result;

    result = rb_block_call(obj, id_each, 0, 0, next_ii, obj);
    e->stop_exc = rb_exc_new2(rb_eStopIteration, "iteration reached an end");
    rb_ivar_set(e->stop_exc, id_result, result);
    return rb_fiber_yield(1, &nil);
}
Example #3
0
static VALUE
next_ii(VALUE i, VALUE obj, int argc, VALUE *argv)
{
    struct enumerator *e = enumerator_ptr(obj);
    VALUE feedvalue = Qnil;
    VALUE args = rb_ary_new4(argc, argv);
    rb_fiber_yield(1, &args);
    if (e->feedvalue != Qundef) {
        feedvalue = e->feedvalue;
        e->feedvalue = Qundef;
    }
    return feedvalue;
}
Example #4
0
static VALUE state_machine_fiber(VALUE data, VALUE self) {
    StateMachineData *stateMachine; Data_Get_Struct(self, StateMachineData, stateMachine);
    VALUE return_argv[1];
    const VALUE *argv = RARRAY_PTR(data);
    int argc = RARRAY_LENINT(data);
    while (TRUE) {
        stateMachine->changed = FALSE;
        return_argv[0] = rb_funcall2(stateMachine->run_method, rb_intern("call"), argc, argv);
        stateMachine->changed = FALSE;
        if (stateMachine->delay > 0) {
            stateMachine->delay--;
            if (stateMachine->delay <= 0) {
                stateMachine->delay = 0;
                rb_funcall(self, rb_intern("change"), 1, stateMachine->reserve_state_name);
                stateMachine->reserve_state_name = Qnil;
            }
        }
        rb_fiber_yield(1, return_argv);
    }
    return Qnil;
}
Example #5
0
static VALUE
next_ii(VALUE i, VALUE obj, int argc, VALUE *argv)
{
    rb_fiber_yield(argc, argv);
    return Qnil;
}
Example #6
0
/*
 *  call-seq:
 *     Fiber.yield(args, ...) -> obj
 *  
 *  Yields control back to the context that resumed the fiber, passing
 *  along any arguments that were passed to it. The fiber will resume
 *  processing at this point when <code>resume</code> is called next.
 *  Any arguments passed to the next <code>resume</code> will be the
 *  value that this <code>Fiber.yield</code> expression evaluates to.
 */
static VALUE
rb_fiber_s_yield(int argc, VALUE *argv, VALUE klass)
{
    return rb_fiber_yield(argc, argv);
}
Example #7
0
static void fiber_schedule_to_main(struct wsgi_request *wsgi_req) {

	rb_fiber_yield(0, NULL);
	uwsgi.wsgi_req = wsgi_req;
}
static VALUE
next_ii(VALUE i, VALUE obj)
{
    rb_fiber_yield(1, &i);
    return Qnil;
}