org.jruby.internal.runtime
Class FutureThread

java.lang.Object
  extended by org.jruby.internal.runtime.FutureThread
All Implemented Interfaces:
ThreadLike

public class FutureThread
extends java.lang.Object
implements ThreadLike

Author:
cnutter

Field Summary
 RubyThread rubyThread
           
 
Constructor Summary
FutureThread(RubyThread rubyThread, RubyRunnable runnable)
           
 
Method Summary
 int getPriority()
          Jobs from the thread pool do not support setting priorities.
 void interrupt()
          In order to do a thread interrupt, we need to get the actual thread, stored in the RubyRunnable instance and tell it to interrupt.
 boolean isAlive()
          If the future has not yet run and or is running and not yet complete.
 boolean isCurrent()
           
 boolean isInterrupted()
           
 void join()
           
 void join(long millis)
          We check for zero millis here because Future appears to wait for zero if you pass it zero, where Thread behavior is to wait forever.
 void setPriority(int priority)
           
 void start()
          Starting a new thread in terms of a thread pool is just submitting it as a job to the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

rubyThread

public RubyThread rubyThread
Constructor Detail

FutureThread

public FutureThread(RubyThread rubyThread,
                    RubyRunnable runnable)
Method Detail

start

public void start()
Starting a new thread in terms of a thread pool is just submitting it as a job to the pool.

Specified by:
start in interface ThreadLike

interrupt

public void interrupt()
In order to do a thread interrupt, we need to get the actual thread, stored in the RubyRunnable instance and tell it to interrupt. Future does not provide a mechanism for passing an interrupt to the thread running it. If the runnable is not being executed by a thread (not yet, or already done) do nothing.

Specified by:
interrupt in interface ThreadLike

isAlive

public boolean isAlive()
If the future has not yet run and or is running and not yet complete.

Specified by:
isAlive in interface ThreadLike

join

public void join()
          throws java.lang.InterruptedException,
                 java.util.concurrent.ExecutionException
Specified by:
join in interface ThreadLike
Throws:
java.lang.InterruptedException
java.util.concurrent.ExecutionException

join

public void join(long millis)
          throws java.lang.InterruptedException,
                 java.util.concurrent.ExecutionException
We check for zero millis here because Future appears to wait for zero if you pass it zero, where Thread behavior is to wait forever. We also catch and swallow CancellationException because it means the Future was cancelled before it ran, and is therefore as done as it will ever be.

Specified by:
join in interface ThreadLike
Parameters:
millis - The number of millis to wait; 0 waits forever.
Throws:
java.lang.InterruptedException - If the blocking join is interrupted by another thread.
java.util.concurrent.ExecutionException - If an execution error is raised by the underlying Future.

getPriority

public int getPriority()
Jobs from the thread pool do not support setting priorities.

Specified by:
getPriority in interface ThreadLike
Returns:

setPriority

public void setPriority(int priority)
Specified by:
setPriority in interface ThreadLike

isCurrent

public boolean isCurrent()
Specified by:
isCurrent in interface ThreadLike

isInterrupted

public boolean isInterrupted()
Specified by:
isInterrupted in interface ThreadLike


Copyright © 2002-2007 JRuby Team. All Rights Reserved.