private static RubyThread adoptThread(final Ruby runtime, final ThreadService service, final RubyClass recv, final Thread thread) { final RubyThread rubyThread = new RubyThread(runtime, recv); rubyThread.threadImpl = new NativeThread(rubyThread, thread); ThreadContext context = service.registerNewThread(rubyThread); service.associateThread(thread, rubyThread); context.preAdoptThread(); // set to default thread group runtime.getDefaultThreadGroup().addDirectly(rubyThread); return rubyThread; }
private IRubyObject startThread(ThreadContext context, Runnable runnable) throws RaiseException, OutOfMemoryError { final Ruby runtime = context.runtime; try { Thread thread = new Thread(runnable); thread.setDaemon(true); this.file = context.getFile(); this.line = context.getLine(); initThreadName(runtime, thread, file, line); threadImpl = new NativeThread(this, thread); addToCorrectThreadGroup(context); // JRUBY-2380, associate thread early so it shows up in Thread.list right away, in case it doesn't run immediately runtime.getThreadService().associateThread(thread, this); // copy parent thread's interrupt masks interruptMaskStack.addAll(context.getThread().interruptMaskStack); threadImpl.start(); // We yield here to hopefully permit the target thread to schedule // MRI immediately schedules it, so this is close but not exact Thread.yield(); return this; } catch (OutOfMemoryError oome) { if (oome.getMessage().equals("unable to create new native thread")) { throw runtime.newThreadError(oome.getMessage()); } throw oome; } catch (SecurityException ex) { throw runtime.newThreadError(ex.getMessage()); } }
runtime.getThreadService().associateThread(futureThread.getFuture(), this); } else { Thread thread = new Thread(runnable); runtime.getThreadService().associateThread(thread, this);
private static RubyThread adoptThread(final Ruby runtime, final ThreadService service, final RubyClass recv, final Thread thread) { final RubyThread rubyThread = new RubyThread(runtime, recv); rubyThread.threadImpl = new NativeThread(rubyThread, thread); ThreadContext context = service.registerNewThread(rubyThread); service.associateThread(thread, rubyThread); context.preAdoptThread(); // set to default thread group runtime.getDefaultThreadGroup().addDirectly(rubyThread); return rubyThread; }
private IRubyObject startThread(ThreadContext context, Runnable runnable) throws RaiseException, OutOfMemoryError { final Ruby runtime = context.runtime; try { Thread thread = new Thread(runnable); thread.setDaemon(true); this.file = context.getFile(); this.line = context.getLine(); initThreadName(runtime, thread, file, line); threadImpl = new NativeThread(this, thread); addToCorrectThreadGroup(context); // JRUBY-2380, associate thread early so it shows up in Thread.list right away, in case it doesn't run immediately runtime.getThreadService().associateThread(thread, this); // copy parent thread's interrupt masks interruptMaskStack.addAll(context.getThread().interruptMaskStack); threadImpl.start(); // We yield here to hopefully permit the target thread to schedule // MRI immediately schedules it, so this is close but not exact Thread.yield(); return this; } catch (OutOfMemoryError oome) { if (oome.getMessage().equals("unable to create new native thread")) { throw runtime.newThreadError(oome.getMessage()); } throw oome; } catch (SecurityException ex) { throw runtime.newThreadError(ex.getMessage()); } }
runtime.getThreadService().associateThread(futureThread.getFuture(), this); } else { Thread thread = new Thread(runnable); runtime.getThreadService().associateThread(thread, this);
private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block block) { final Ruby runtime = recv.getRuntime(); final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) recv); rubyThread.threadImpl = new NativeThread(rubyThread, t); ThreadContext context = runtime.getThreadService().registerNewThread(rubyThread); runtime.getThreadService().associateThread(t, rubyThread); context.preAdoptThread(); // set to default thread group runtime.getDefaultThreadGroup().addDirectly(rubyThread); return rubyThread; }
private static RubyThread adoptThread(final IRubyObject recv, Thread t, Block block) { final Ruby runtime = recv.getRuntime(); final RubyThread rubyThread = new RubyThread(runtime, (RubyClass) recv); rubyThread.threadImpl = new NativeThread(rubyThread, t); ThreadContext context = runtime.getThreadService().registerNewThread(rubyThread); runtime.getThreadService().associateThread(t, rubyThread); context.preAdoptThread(); // set to default thread group runtime.getDefaultThreadGroup().addDirectly(rubyThread); return rubyThread; }