[Swift-commit] cog r3903
swift at ci.uchicago.edu
swift at ci.uchicago.edu
Thu May 8 23:25:03 CDT 2014
------------------------------------------------------------------------
r3903 | hategan | 2014-05-08 23:24:09 -0500 (Thu, 08 May 2014) | 1 line
misc improvements
------------------------------------------------------------------------
Index: modules/karajan/src/k/thr/LWThread.java
===================================================================
--- modules/karajan/src/k/thr/LWThread.java (revision 3902)
+++ modules/karajan/src/k/thr/LWThread.java (working copy)
@@ -462,6 +462,10 @@
}
return cid;
}
+
+ public int getForkID() {
+ return forkId;
+ }
public final synchronized void sleep(long delay) {
sleep(delay, 0);
@@ -551,7 +555,20 @@
return child;
}
+
+ public final synchronized LWThread fork(int id, KRunnable r) {
+ if (DEBUG)
+ System.out.println(this + " fork(" + state + ")");
+ LWThread child = new LWThread(id, r, stack.copy());
+
+ if (DEBUG) {
+ Exception e = new Exception();
+ System.out.println(child + " forked by " + e.getStackTrace()[1].getClassName());
+ }
+ return child;
+ }
+
public final void die() {
if (DEBUG)
System.out.println(this + " die()");
Index: modules/karajan/src/k/thr/Scheduler.java
===================================================================
--- modules/karajan/src/k/thr/Scheduler.java (revision 3902)
+++ modules/karajan/src/k/thr/Scheduler.java (working copy)
@@ -47,8 +47,12 @@
Clock.init();
}
- public synchronized void awake(final LWThread thread) {
- if (sleeping.remove(thread)) {
+ public void awake(final LWThread thread) {
+ boolean wasSleeping;
+ synchronized(sleeping) {
+ wasSleeping = sleeping.remove(thread);
+ }
+ if (wasSleeping) {
//System.err.println("awake(" + thread + ")");
schedule(thread);
}
@@ -85,10 +89,12 @@
return workers.getActiveCount() > 0 || !queue.isEmpty();
}
- public synchronized void putToSleep(final LWThread thread) {
+ public void putToSleep(final LWThread thread) {
if (thread.isSleeping()) {
//System.err.println("putToSleep(" + thread + ")");
- sleeping.add(thread);
+ synchronized(sleeping) {
+ sleeping.add(thread);
+ }
}
}
@@ -147,6 +153,8 @@
}
public List<LWThread> getSleepingThreads() {
- return new ArrayList<LWThread>(sleeping);
+ synchronized(sleeping) {
+ return new ArrayList<LWThread>(sleeping);
+ }
}
}
More information about the Swift-commit
mailing list