mirror of
https://github.com/bspeice/itcs3146-project
synced 2024-12-30 10:38:24 -05:00
IDE Bug fixes, and don't commit IDE files
This commit is contained in:
parent
a466157d5f
commit
1525dc4d41
3
.gitignore
vendored
3
.gitignore
vendored
@ -1 +1,4 @@
|
||||
*.swp
|
||||
*.class
|
||||
.classpath
|
||||
.project
|
||||
|
8
Job.java
8
Job.java
@ -1,3 +1,5 @@
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/*
|
||||
* Author: Bradlee Speice
|
||||
* Job Class
|
||||
@ -12,11 +14,11 @@ public class Job {
|
||||
private jobThread myThread; //Reference to the thread we control
|
||||
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
|
||||
myThread = new jobThread(jobTime, jobID, parentAlgorithmDeallocate);
|
||||
myThread = new jobThread(jobTime, jobID, parentAlgorithmDeallocate, jobSize, beginningLocation);
|
||||
myThread.start();
|
||||
myThreadPause = false;
|
||||
myThreadPaused = false;
|
||||
}
|
||||
|
||||
public void pause(){
|
||||
|
@ -1,16 +1,5 @@
|
||||
public class baseAlgorithm{
|
||||
interface baseAlgorithm{
|
||||
|
||||
int[] memoryBlock;
|
||||
|
||||
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){
|
||||
|
||||
}
|
||||
void allocate(int jobID, int jobSize, int jobTime);
|
||||
void deallocate(int jobSize, int beginningLocation);
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
public class dummyAlgorithm{
|
||||
public class dummyAlgorithm implements baseAlgorithm{
|
||||
|
||||
int[] memoryBlock;
|
||||
|
||||
@ -7,11 +7,11 @@ public class dummyAlgorithm{
|
||||
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 */
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
public class jobThread extends Thread {
|
||||
private final int sleepResolution = 200; //Milliseconds
|
||||
private long jobTime; //Milliseconds
|
||||
@ -8,14 +10,19 @@ public class jobThread extends Thread {
|
||||
private boolean jobDone;
|
||||
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.parentAlgorithmDeallocate = parentAlgorithmDeallocate;
|
||||
elapsedTime = 0;
|
||||
isPaused = false;
|
||||
startTime = 0;
|
||||
this.elapsedTime = 0;
|
||||
this.isPaused = false;
|
||||
this.startTime = 0;
|
||||
this.jobID = jobID;
|
||||
//this.parentAlgorithm = parentAlgorithm;
|
||||
this.jobSize = jobSize;
|
||||
this.beginningLocation = beginningLocation;
|
||||
}
|
||||
|
||||
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
|
||||
parentAlgorithmDeallocate(jobID);
|
||||
parentAlgorithmDeallocate.invoke(this.jobSize, this.beginningLocation);
|
||||
} catch (Exception e) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user