@JRubyMethod(meta = true) public static IRubyObject __current__(ThreadContext context, IRubyObject recv) { return context.getFiber(); }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, Block block) { Ruby runtime = context.runtime; if (!block.isGiven()) throw runtime.newArgumentError("tried to create Proc object without block"); data = new FiberData(new FiberQueue(runtime), context.getFiberCurrentThread(), this); FiberData currentFiberData = context.getFiber().data; thread = createThread(runtime, data, currentFiberData.queue, block); return context.nil; }
@JRubyMethod(visibility = Visibility.PRIVATE) public IRubyObject initialize(ThreadContext context, Block block) { Ruby runtime = context.runtime; if (!block.isGiven()) throw runtime.newArgumentError("tried to create Proc object without block"); data = new FiberData(new FiberQueue(runtime), context.getFiberCurrentThread(), this); FiberData currentFiberData = context.getFiber().data; thread = createThread(runtime, data, currentFiberData.queue, block); return context.nil; }
protected final ExecutionContext getExecutionContext(ThreadContext context) { final ExecutionContext fiber; fiber = context.getFiber(); if (fiber != null) { return fiber; } else { /* root fiber */ return context.getThread(); } }
@JRubyMethod public IRubyObject initialize(ThreadContext context, Block block) { Ruby runtime = context.runtime; if (!block.isGiven()) throw runtime.newArgumentError("tried to create Proc object without block"); data = new FiberData(new SizedQueue(runtime, runtime.getClass("SizedQueue")), context.getFiberCurrentThread(), this); FiberData currentFiberData = context.getFiber().data; thread = createThread(runtime, data, currentFiberData.queue, block); return context.nil; }
protected final ExecutionContext getExecutionContext(ThreadContext context) { final ExecutionContext fiber; fiber = context.getFiber(); if (fiber != null) { return fiber; } else { /* root fiber */ return context.getThread(); } }
@JRubyMethod public IRubyObject initialize(ThreadContext context, Block block) { Ruby runtime = context.runtime; if (!block.isGiven()) throw runtime.newArgumentError("tried to create Proc object without block"); data = new FiberData(new SizedQueue(runtime, runtime.getClass("SizedQueue")), context.getFiberCurrentThread(), this); FiberData currentFiberData = context.getFiber().data; thread = createThread(runtime, data, currentFiberData.queue, block); return context.nil; }
protected final ExecutionContext getExecutionContext(ThreadContext context) { final ExecutionContext fiber; fiber = context.getFiber(); if (fiber != null) { return fiber; } else { /* root fiber */ return context.getThread(); } }
protected final ExecutionContext getExecutionContext(ThreadContext context) { final ExecutionContext fiber; fiber = context.getFiber(); if (fiber != null) { return fiber; } else { /* root fiber */ return context.getThread(); } }
@JRubyMethod(meta = true) public static IRubyObject __current__(ThreadContext context, IRubyObject recv) { return context.getFiber(); }
@JRubyMethod(meta = true) public static IRubyObject __current__(ThreadContext context, IRubyObject recv) { return context.getFiber(); }
@JRubyMethod(meta = true) public static IRubyObject __current__(ThreadContext context, IRubyObject recv) { return context.getFiber(); }
@JRubyMethod(meta = true) public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject value) { Ruby runtime = context.runtime; FiberData currentFiberData = context.getFiber().data; if (currentFiberData.parent == null) throw runtime.newFiberError("can't yield from root fiber"); FiberData prevFiberData = currentFiberData.prev.data; prevFiberData.queue.push(context, value); IRubyObject result = currentFiberData.queue.pop(context); if (result == NEVER) result = context.nil; return result; }
@JRubyMethod(meta = true) public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject value) { Ruby runtime = context.runtime; FiberData currentFiberData = context.getFiber().data; if (currentFiberData.parent == null) throw runtime.newFiberError("can't yield from root fiber"); if (currentFiberData.prev == null) throw runtime.newFiberError("BUG: yield occurred with null previous fiber. Report this at http://bugs.jruby.org"); if (currentFiberData.queue.isShutdown()) throw runtime.newFiberError("dead fiber yielded"); FiberData prevFiberData = currentFiberData.prev.data; return exchangeWithFiber(context, currentFiberData, prevFiberData, value); }
@JRubyMethod(meta = true) public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject value) { Ruby runtime = context.runtime; FiberData currentFiberData = context.getFiber().data; if (currentFiberData.parent == null) throw runtime.newFiberError("can't yield from root fiber"); if (currentFiberData.prev == null) throw runtime.newFiberError("BUG: yield occured with null previous fiber. Report this at http://bugs.jruby.org"); if (currentFiberData.queue.isShutdown()) throw runtime.newFiberError("dead fiber yielded"); FiberData prevFiberData = currentFiberData.prev.data; return exchangeWithFiber(context, currentFiberData, prevFiberData, value); }
@JRubyMethod(meta = true) public static IRubyObject yield(ThreadContext context, IRubyObject recv, IRubyObject value) { Ruby runtime = context.runtime; FiberData currentFiberData = context.getFiber().data; if (currentFiberData.parent == null) throw runtime.newFiberError("can't yield from root fiber"); if (currentFiberData.prev == null) throw runtime.newFiberError("BUG: yield occurred with null previous fiber. Report this at http://bugs.jruby.org"); if (currentFiberData.queue.isShutdown()) throw runtime.newFiberError("dead fiber yielded"); FiberData prevFiberData = currentFiberData.prev.data; return exchangeWithFiber(context, currentFiberData, prevFiberData, value); }
/** * Find the active Continuation for the given tag. Must be called with an * interned string. * * @param tag The interned string to search for * @return The continuation associated with this tag */ public Continuation getActiveCatch(Object tag) { for (int i = catchIndex; i >= 0; i--) { Continuation c = catchStack[i]; if (c.tag == tag) return c; } // if this is a fiber, search prev for tag ThreadFiber fiber = getFiber(); ThreadFiber prev; if (fiber != null && (prev = fiber.getData().getPrev()) != null) { return prev.getThread().getContext().getActiveCatch(tag); } return null; }
/** * Find the active Continuation for the given tag. Must be called with an * interned string. * * @param tag The interned string to search for * @return The continuation associated with this tag */ public Continuation getActiveCatch(Object tag) { for (int i = catchIndex; i >= 0; i--) { Continuation c = catchStack[i]; if (runtime.is1_9()) { if (c.tag == tag) return c; } else { if (c.tag.equals(tag)) return c; } } // if this is a fiber, search prev for tag ThreadFiber fiber = getFiber(); ThreadFiber prev; if (fiber != null && (prev = fiber.getData().getPrev()) != null) { return prev.getThread().getContext().getActiveCatch(tag); } return null; }
/** * Find the active Continuation for the given tag. Must be called with an * interned string. * * @param tag The interned string to search for * @return The continuation associated with this tag */ public Continuation getActiveCatch(Object tag) { for (int i = catchIndex; i >= 0; i--) { Continuation c = catchStack[i]; if (c.tag == tag) return c; } // if this is a fiber, search prev for tag ThreadFiber fiber = getFiber(); ThreadFiber prev; if (fiber != null && (prev = fiber.getData().getPrev()) != null) { return prev.getThread().getContext().getActiveCatch(tag); } return null; }