IDE Bug fixes, and don't commit IDE files

This commit is contained in:
Bradlee Speice 2012-11-06 20:12:32 -05:00
parent a466157d5f
commit 1525dc4d41
5 changed files with 27 additions and 29 deletions

3
.gitignore vendored
View File

@ -1 +1,4 @@
*.swp *.swp
*.class
.classpath
.project

View File

@ -1,3 +1,5 @@
import java.lang.reflect.Method;
/* /*
* Author: Bradlee Speice * Author: Bradlee Speice
* Job Class * Job Class
@ -12,11 +14,11 @@ public class Job {
private jobThread myThread; //Reference to the thread we control private jobThread myThread; //Reference to the thread we control
private boolean myThreadPaused; //Used to keep track of the execution state of our thread private boolean myThreadPaused; //Used to keep track of the execution state of our thread
public Job(int jobTime, int jobID, Method parentAlgorithmDeallocate ){ public Job(int jobTime, int jobID, Method parentAlgorithmDeallocate, int jobSize, int beginningLocation ){
//Create a new job, and start it running //Create a new job, and start it running
myThread = new jobThread(jobTime, jobID, parentAlgorithmDeallocate); myThread = new jobThread(jobTime, jobID, parentAlgorithmDeallocate, jobSize, beginningLocation);
myThread.start(); myThread.start();
myThreadPause = false; myThreadPaused = false;
} }
public void pause(){ public void pause(){

View File

@ -1,16 +1,5 @@
public class baseAlgorithm{ interface baseAlgorithm{
int[] memoryBlock; void allocate(int jobID, int jobSize, int jobTime);
void deallocate(int jobSize, int beginningLocation);
void baseAlgorithm(int memorySize){
/* Constructor needed for each algorithm */
memoryBlock = new int[memorySize];
}
void allocate(int jobID, int jobSize, int jobTime){
/* This method to be overloaded by each algorithm */
}
void deallocate(int jobSize, int beginningLocation){
}
} }

View File

@ -1,4 +1,4 @@
public class dummyAlgorithm{ public class dummyAlgorithm implements baseAlgorithm{
int[] memoryBlock; int[] memoryBlock;
@ -7,11 +7,11 @@ public class dummyAlgorithm{
memoryBlock = new int[memorySize]; memoryBlock = new int[memorySize];
} }
void allocate(int jobID, int jobSize, int jobTime){ public void allocate(int jobID, int jobSize, int jobTime){
/* This method to be overloaded by each algorithm */ /* This method to be overloaded by each algorithm */
System.out.println("Allocating job " + jobID + " with size: " + jobSize + " for: " + jobTime + " milliseconds."); System.out.println("Allocating job " + jobID + " with size: " + jobSize + " for: " + jobTime + " milliseconds.");
} }
void deallocate(int jobSize, int beginningLocation){ public void deallocate(int jobSize, int beginningLocation){
System.out.println("Removing job with size: " + jobSize + " beginning at: " + beginningLocation); System.out.println("Removing job with size: " + jobSize + " beginning at: " + beginningLocation);
} }
} }

View File

@ -1,3 +1,5 @@
import java.lang.reflect.Method;
public class jobThread extends Thread { public class jobThread extends Thread {
private final int sleepResolution = 200; //Milliseconds private final int sleepResolution = 200; //Milliseconds
private long jobTime; //Milliseconds private long jobTime; //Milliseconds
@ -8,14 +10,19 @@ public class jobThread extends Thread {
private boolean jobDone; private boolean jobDone;
private Method parentAlgorithmDeallocate; //Our parent to notify when we're done. private Method parentAlgorithmDeallocate; //Our parent to notify when we're done.
public jobThread(long jobTime, int jobID, Method parentAlgorithmDeallocate){ /* Fields that we need to know when calling the deallocate */
private int jobSize;
private int beginningLocation;
public jobThread(long jobTime, int jobID, Method parentAlgorithmDeallocate, int jobSize, int beginningLocation){
this.jobTime = jobTime; this.jobTime = jobTime;
this.parentAlgorithmDeallocate = parentAlgorithmDeallocate; this.parentAlgorithmDeallocate = parentAlgorithmDeallocate;
elapsedTime = 0; this.elapsedTime = 0;
isPaused = false; this.isPaused = false;
startTime = 0; this.startTime = 0;
this.jobID = jobID; this.jobID = jobID;
//this.parentAlgorithm = parentAlgorithm; this.jobSize = jobSize;
this.beginningLocation = beginningLocation;
} }
public void pause(){ public void pause(){
@ -70,12 +77,9 @@ public class jobThread extends Thread {
} }
//We're done, go ahead and notify our algorithm to clean us up //We're done, go ahead and notify our algorithm to clean us up
parentAlgorithmDeallocate(jobID); parentAlgorithmDeallocate.invoke(this.jobSize, this.beginningLocation);
} catch (Exception e) { } catch (Exception e) {
return; return;
} }
} }
} }