Skip to content
Browse files

Cosmetic changes

  • Loading branch information...
1 parent 3985ebd commit a3c018bdc7b5a9db1bdcf23255b77bbed231bca9 sriram srinivasan committed
Showing with 16 additions and 10 deletions.
  1. +10 −6 src/kilim/Scheduler.java
  2. +3 −3 src/kilim/Task.java
  3. +3 −1 src/kilim/WorkerThread.java
View
16 src/kilim/Scheduler.java
@@ -18,12 +18,12 @@
*
*/
public class Scheduler {
- static Scheduler defaultScheduler = null;
- static int defaultNumberThreads;
- LinkedList<WorkerThread> allThreads = new LinkedList<WorkerThread>();
- LinkedList<WorkerThread> waitingThreads = new LinkedList<WorkerThread>();
+ public static Scheduler defaultScheduler = null;
+ public static int defaultNumberThreads;
+ public LinkedList<WorkerThread> allThreads = new LinkedList<WorkerThread>();
+ public LinkedList<WorkerThread> waitingThreads = new LinkedList<WorkerThread>();
protected boolean shutdown = false;
- protected RingQueue<Task> runnableTasks = new RingQueue<Task>(100);
+ public RingQueue<Task> runnableTasks = new RingQueue<Task>(100);
static {
String s = System.getProperty("kilim.Scheduler.numThreads");
@@ -50,7 +50,6 @@ public Scheduler(int numThreads) {
/**
* Schedule a task to run. It is the task's job to ensure that
* it is not scheduled when it is runnable.
- * ensure that
*/
public void schedule(Task t) {
WorkerThread wt = null;
@@ -75,6 +74,11 @@ public void shutdown() {
}
}
+ /**
+ * This is called in the WorkerThread's stack and blocks until a task is available
+ *
+ * @return
+ */
Task getNextTask(WorkerThread wt) {
while (true) {
Task t = null;
View
6 src/kilim/Task.java
@@ -95,9 +95,9 @@ public int id() {
}
public synchronized Task setScheduler(Scheduler s) {
- if (running) {
- throw new AssertionError("Attempt to change task's scheduler while it is running");
- }
+// if (running) {
+// throw new AssertionError("Attempt to change task's scheduler while it is running");
+// }
scheduler = s;
return this;
}
View
4 src/kilim/WorkerThread.java
@@ -9,6 +9,7 @@
import java.util.LinkedList;
import java.util.HashMap;
import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.atomic.AtomicInteger;
public class WorkerThread extends Thread {
Task runningTask;
@@ -19,10 +20,11 @@
*/
RingQueue<Task> tasks = new RingQueue<Task>(10);
Scheduler scheduler;
-
+ static AtomicInteger gid = new AtomicInteger();
public int numResumes = 0;
WorkerThread(Scheduler ascheduler) {
+ super("KilimWorker-" + gid.incrementAndGet());
scheduler=ascheduler;
}

0 comments on commit a3c018b

Please sign in to comment.
Something went wrong with that request. Please try again.