All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jruby.ext.fiber.FiberMeta Maven / Gradle / Ivy

There is a newer version: 9.4.7.0
Show newest version
package org.jruby.ext.fiber;

import org.jruby.CompatVersion;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

public class FiberMeta {
    @JRubyMethod(compat = CompatVersion.RUBY1_9, meta = true)
    public static IRubyObject yield(ThreadContext context, IRubyObject recv) {
        Fiber fiber = context.getFiber();
        if (fiber.isRoot()) {
            throw context.getRuntime().newFiberError("can't yield from root fiber");
        }
        return fiber.yield(context, context.nil);
    }

    @JRubyMethod(compat = CompatVersion.RUBY1_9, meta = true)
    public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject arg) {
        Fiber fiber = context.getFiber();
        if (fiber.isRoot()) {
            throw context.getRuntime().newFiberError("can't yield from root fiber");
        }
        return fiber.yield(context, arg);
    }

    @JRubyMethod(compat = CompatVersion.RUBY1_9, rest = true)
    public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject[] args) {
        Fiber fiber = context.getFiber();
        if (fiber.isRoot()) {
            throw context.getRuntime().newFiberError("can't yield from root fiber");
        }
        return fiber.yield(context, context.getRuntime().newArrayNoCopyLight(args));
    }
    
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy