Package org.jruby.internal.runtime

Examples of org.jruby.internal.runtime.ThreadService


    }

    @JRubyMethod(name = "pass", meta = true)
    public static IRubyObject pass(IRubyObject recv) {
        Ruby runtime = recv.getRuntime();
        ThreadService ts = runtime.getThreadService();
        boolean critical = ts.getCritical();
       
        ts.setCritical(false);
       
        Thread.yield();
       
        ts.setCritical(critical);
       
        return recv.getRuntime().getNil();
    }
View Full Code Here


     * @param config The configuration to use for the new instance
     * @see org.jruby.RubyInstanceConfig
     */
    private Ruby(RubyInstanceConfig config) {
        this.config             = config;
        this.threadService      = new ThreadService(this);
        if(config.isSamplingEnabled()) {
            org.jruby.util.SimpleSampler.registerThreadContext(threadService.getCurrentContext());
        }

        this.in                 = config.getInput();
View Full Code Here

    }

    public static class ThreadMethods {
        @JRubyMethod(name = "exclusive", meta = true, compat = RUBY1_8)
        public static IRubyObject exclusive(ThreadContext context, IRubyObject receiver, Block block) {
            ThreadService service  = context.getRuntime().getThreadService();
            boolean old = service.getCritical();
            try {
                service.setCritical(true);
                return block.yield(receiver.getRuntime().getCurrentContext(), (IRubyObject) null);
            } finally {
                service.setCritical(old);
            }
        }
View Full Code Here

        final String threadDumpSignal = runtime.getInstanceConfig().getThreadDumpSignal();
        if (threadDumpSignal != null && threadDumpSignal.length() > 0) {
            SIGNALS.trap(runtime, new BlockCallback() {
                public IRubyObject call(ThreadContext context, IRubyObject[] args, Block block) {
                    System.err.println("Ruby Thread Dump");
                    final ThreadService threadService = runtime.getThreadService();
                    RubyThread[] thrs = threadService.getActiveRubyThreads();
                    for (RubyThread th : thrs) {
                        System.err.println("\n" + th);
                        RubyException exc = new RubyException(runtime, runtime.getRuntimeError(), "");
                        ThreadContext tc = threadService.getThreadContextForThread(th);
                        if (tc != null) {
                            exc.setBacktraceData(new BacktraceData(th.javaBacktrace(), tc.createBacktrace2(0, false), false, false, Gather.NORMAL));
                            exc.printBacktrace(System.err);
                        } else {
                            System.err.println("    [no longer alive]");
View Full Code Here

     */
    private Ruby(RubyInstanceConfig config) {
        this.config             = config;
        this.is1_9              = config.getCompatVersion() == CompatVersion.RUBY1_9;
        this.doNotReverseLookupEnabled = is1_9;
        this.threadService      = new ThreadService(this);
        if(config.isSamplingEnabled()) {
            org.jruby.util.SimpleSampler.registerThreadContext(threadService.getCurrentContext());
        }

        this.in                 = config.getInput();
View Full Code Here

    }

    @JRubyMethod(name = "pass", meta = true)
    public static IRubyObject pass(IRubyObject recv) {
        Ruby runtime = recv.getRuntime();
        ThreadService ts = runtime.getThreadService();
        boolean critical = ts.getCritical();
       
        ts.setCritical(false);
       
        Thread.yield();
       
        ts.setCritical(critical);
       
        return recv.getRuntime().getNil();
    }
View Full Code Here

    }

    @JRubyMethod(name = "pass", meta = true)
    public static IRubyObject pass(IRubyObject recv) {
        Ruby runtime = recv.getRuntime();
        ThreadService ts = runtime.getThreadService();
        boolean critical = ts.getCritical();
       
        ts.setCritical(false);
       
        Thread.yield();
       
        ts.setCritical(critical);
       
        return recv.getRuntime().getNil();
    }
View Full Code Here

     * @param config The configuration to use for the new instance
     * @see org.jruby.RubyInstanceConfig
     */
    private Ruby(RubyInstanceConfig config) {
        this.config             = config;
        this.threadService      = new ThreadService(this);
        if(config.isSamplingEnabled()) {
            org.jruby.util.SimpleSampler.registerThreadContext(threadService.getCurrentContext());
        }
       
        if (config.getCompileMode() == CompileMode.OFFIR ||
View Full Code Here

* Methods added to the Thread class.
*/
public class ThreadMethods {
    @JRubyMethod(name = "exclusive", meta = true, compat = CompatVersion.RUBY1_8)
    public static IRubyObject exclusive(ThreadContext context, IRubyObject receiver, Block block) {
        ThreadService service = context.runtime.getThreadService();
        boolean old = service.getCritical();
        try {
            service.setCritical(true);
            return block.yield(receiver.getRuntime().getCurrentContext(), (IRubyObject) null);
        } finally {
            service.setCritical(old);
        }
    }
View Full Code Here

     * @param config The configuration to use for the new instance
     * @see org.jruby.RubyInstanceConfig
     */
    private Ruby(RubyInstanceConfig config) {
        this.config             = config;
        this.threadService      = new ThreadService(this);

        if( config.isProfiling() ) {
            this.profiledMethods        = new ProfiledMethods(this);
            this.profilingServiceLookup = new ProfilingServiceLookup(this);
        } else {
View Full Code Here

TOP

Related Classes of org.jruby.internal.runtime.ThreadService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.