mjc

org.multijava.mjc
Class Main.Task

java.lang.Object
  extended byorg.multijava.mjc.Main.Task
All Implemented Interfaces:
Comparable
Direct Known Subclasses:
Main.ParseTask, Main.TreeProcessingTask
Enclosing class:
Main

public abstract class Main.Task
extends Object
implements Comparable

This abstract class represents a single task to be performed by the compiler. A task is a single pass of the compiler, performed on one or (for efficiency) several compilation units. Each concrete task has a priority which is used for ordering tasks in a priority queue. This technique allows the compilation of transitively referenced files to be "caught up" with the compilation of files named at the command line.


Field Summary
private  int priority
           
private  Object sequenceID
           
private  int uniqueNumber
          This is a unique number assigned to each task and used in compareTo(Object) to differentiate between two tasks with the same priority.
 
Constructor Summary
Main.Task(int priority, Object sequenceID)
          Creates a new task of the given priority and sequenceID.
 
Method Summary
 int compareTo(Object other)
          Compare tasks, ensuring that tasks of equal priority are not equal.
abstract  void execute()
          Executes the task represented by this.
 int priority()
          Returns the relative priority of this task.
 Object sequenceID()
          Returns the unique sequenceID for tasks in this sequence.
 Main.Task setToMainSequenceID()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

priority

private int priority

sequenceID

private Object sequenceID

uniqueNumber

private int uniqueNumber
This is a unique number assigned to each task and used in compareTo(Object) to differentiate between two tasks with the same priority.

Constructor Detail

Main.Task

public Main.Task(int priority,
                 Object sequenceID)
Creates a new task of the given priority and sequenceID. The priority is used to schedule tasks in the taskQueue. We use the term task sequence to refer to a sequence of tasks from parsing through to the end of compilation such that every task in the sequence except the first was returned by a call to createTaskAfter(t) where t is the previous task in the sequence. The sequenceID is a common identifier that is passed along to each task in a given task sequence. For example, suppose file F1.java is given to the compile as the file to be processed and further suppose that it refers to code found in a file F2.java. Initially a task will be create for compiling F1.java. Suppose this task has a sequenceID 'x'. After parsing a new task will be created for the next stage of processing for F1.java; this new task will also have the sequenceID 'x'. Now if in this stage the compiler decides it needs to process F2.java, then F2.java is added to the task queue by creating a new task. This task will have a sequenceID 'y' where y != x. Among other things the compiler can use these sequenceIDs to differentiate tasks in compilation sequences initiated by the command line arguments vs. those initiated by calls to catchUp.

 ensures !completed;
 

Method Detail

priority

public final int priority()
Returns the relative priority of this task. Smaller values signify higher priority.


sequenceID

public final Object sequenceID()
Returns the unique sequenceID for tasks in this sequence.


setToMainSequenceID

public final Main.Task setToMainSequenceID()

compareTo

public final int compareTo(Object other)
Compare tasks, ensuring that tasks of equal priority are not equal.

 also 
 old Task otherTask = (Task) other;
 requires other instanceof Task;
 {|
   requires priority != otherTask.priority;
   ensures \result == priority - otherTask.priority;
 also
   requires priority == otherTask.priority;
   ensures \result == 0 <==> this == otherTask;
 |}
 

Specified by:
compareTo in interface Comparable

execute

public abstract void execute()
Executes the task represented by this.

 requires !completed;
 ensures completed;
 


mjc

mjc is Copyright (C) 2000-2004 by Iowa State University and is distributed under the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. mjc is based in part on the Kopi project Copyright (C) 1990-99 DMS Decision Management Systems Ges.m.b.H.