VALUE rb_fiber_schedule_to_req() { int id = uwsgi.wsgi_req->async_id; if (!uwsgi.wsgi_req->suspended) { ufiber.fib[id] = rb_fiber_new(uwsgi_fiber_request, Qnil); rb_gc_register_address(&ufiber.fib[id]); uwsgi.wsgi_req->suspended = 1; } rb_fiber_resume(ufiber.fib[id], 0, NULL); if (uwsgi.wsgi_req->suspended) { uwsgi.wsgi_req->async_status = UWSGI_AGAIN; } return Qnil; }
static VALUE enumerator_next(VALUE obj) { struct enumerator *e = enumerator_ptr(obj); VALUE curr, v; curr = rb_fiber_current(); if (!e->fib || !rb_fiber_alive_p(e->fib)) { next_init(obj, e); } v = rb_fiber_resume(e->fib, 1, &curr); if (e->no_next) { e->fib = 0; e->dst = Qnil; e->no_next = Qfalse; rb_raise(rb_eStopIteration, "iteration reached at end"); } return v; }
static VALUE get_next_values(VALUE obj, struct enumerator *e) { VALUE curr, vs; if (e->stop_exc) rb_exc_raise(e->stop_exc); curr = rb_fiber_current(); if (!e->fib || !rb_fiber_alive_p(e->fib)) { next_init(obj, e); } vs = rb_fiber_resume(e->fib, 1, &curr); if (e->stop_exc) { e->fib = 0; e->dst = Qnil; e->lookahead = Qundef; e->feedvalue = Qundef; rb_exc_raise(e->stop_exc); } return vs; }
/* * call-seq: * fiber.resume(args, ...) -> obj * * Resumes the fiber from the point at which the last <code>Fiber.yield</code> * was called, or starts running it if it is the first call to * <code>resume</code>. Arguments passed to resume will be the value of * the <code>Fiber.yield</code> expression or will be passed as block * parameters to the fiber's block if this is the first <code>resume</code>. * * Alternatively, when resume is called it evaluates to the arguments passed * to the next <code>Fiber.yield</code> statement inside the fiber's block * or to the block value if it runs to completion without any * <code>Fiber.yield</code> */ static VALUE rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib) { return rb_fiber_resume(fib, argc, argv); }