Repository: incubator-reef
Updated Branches:
  refs/heads/master 53bed07a9 -> 75a2af245


[REEF-368]: Avoid holding Wake schedule lock while calling event handlers

This removes the call to handle an idle event to before the schedule
lock is taken.

This should avoid the deadlock situation seen in REEF-294, where a
separate thread holds a lock needed by the idle event handler, and then
waits for the schedule lock. Now the idle event handler call will not be
holding the schedule lock.

JIRA:
  [REEF-368] https://issues.apache.org/jira/browse/REEF-368

Pull Request:
  This closes #218


Project: http://git-wip-us.apache.org/repos/asf/incubator-reef/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-reef/commit/75a2af24
Tree: http://git-wip-us.apache.org/repos/asf/incubator-reef/tree/75a2af24
Diff: http://git-wip-us.apache.org/repos/asf/incubator-reef/diff/75a2af24

Branch: refs/heads/master
Commit: 75a2af245e1e13afed5311c2a8552a6818bb479a
Parents: 53bed07
Author: Brian Cho <[email protected]>
Authored: Mon Jun 15 11:54:34 2015 +0900
Committer: Markus Weimer <[email protected]>
Committed: Mon Jun 15 08:56:16 2015 -0700

----------------------------------------------------------------------
 .../org/apache/reef/wake/time/runtime/RuntimeClock.java     | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-reef/blob/75a2af24/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/time/runtime/RuntimeClock.java
----------------------------------------------------------------------
diff --git 
a/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/time/runtime/RuntimeClock.java
 
b/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/time/runtime/RuntimeClock.java
index d8f27da..f4b97d4 100644
--- 
a/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/time/runtime/RuntimeClock.java
+++ 
b/lang/java/reef-wake/wake/src/main/java/org/apache/reef/wake/time/runtime/RuntimeClock.java
@@ -197,12 +197,13 @@ public final class RuntimeClock implements Clock {
       while (true) {
         LOG.log(Level.FINEST, "Entering clock main loop iteration.");
         try {
+          if (this.isIdle()) {
+            // Handle an idle clock event, without locking this.schedule
+            this.handlers.onNext(new IdleClock(timer.getCurrent()));
+          }
+
           Time time = null;
           synchronized (this.schedule) {
-            if (this.isIdle()) {
-              this.handlers.onNext(new IdleClock(timer.getCurrent()));
-            }
-
             while (this.schedule.isEmpty()) {
               this.schedule.wait();
             }

Reply via email to