Class Kernel.Launcher

Object
  extended byThread
      extended byKernel.Launcher
All Implemented Interfaces:
Runnable
Enclosing class:
Kernel

private static class Kernel.Launcher
extends Thread

A Launcher instance represents one atomic command being run by the Kernel. It has associated with it a process id (pid), a Java method to run, and a list of arguments to the method. Do not modify any part of this class.


Field Summary
private  Object[] arglist
          The list of arguments to this command.
private  Method method
          The method being run by this command.
private static int nextpid
          Source of unique ids for Launcher instances.
private  Integer pid
          The process id of this command.
(package private) static Map pidMap
          Mapping of process ids (encoded as Integers) to Launcher instances.
private  int returnCode
          Return code returned by this command (0 if the command has not yet completed.
 
Fields inherited from class Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
Kernel.Launcher(String command, String[] args)
          Creates a new Launcher for a program.
 
Method Summary
 void delete()
          Removes this Launcher from the set of all active Launchers.
static void joinAll()
          Waits for all existing Launchers to complete.
static int joinOne(int pid)
          Waits for a particular Launcher to complete.
 void run()
          Main loop of the Launcher
 
Methods inherited from class Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getContextClassLoader, getName, getPriority, getThreadGroup, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setName, setPriority, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

pidMap

static Map pidMap
Mapping of process ids (encoded as Integers) to Launcher instances.


nextpid

private static int nextpid
Source of unique ids for Launcher instances.


method

private Method method
The method being run by this command.


arglist

private Object[] arglist
The list of arguments to this command.


pid

private Integer pid
The process id of this command.


returnCode

private int returnCode
Return code returned by this command (0 if the command has not yet completed.

Constructor Detail

Kernel.Launcher

public Kernel.Launcher(String command,
                       String[] args)
                throws ClassNotFoundException,
                       NoSuchMethodException
Creates a new Launcher for a program.

Parameters:
command - the name of the program (new name of a class with a main(String[]) method.
args - command-line arguments to the program.
Method Detail

run

public void run()
Main loop of the Launcher


joinAll

public static void joinAll()
Waits for all existing Launchers to complete.


joinOne

public static int joinOne(int pid)
Waits for a particular Launcher to complete.

Parameters:
pid - the process id of the desired process.
Returns:
the return code of the indicated process, or ERROR_NO_SUCH_PROCESS if the pid is invalid.

delete

public void delete()
Removes this Launcher from the set of all active Launchers.