From 92156fd8a07a8541994b02519634b934ffd99ac7 Mon Sep 17 00:00:00 2001 From: Nick Battle Date: Fri, 27 Sep 2013 11:53:22 +0100 Subject: [PATCH] Correction for deadlocked CT test cases --- .../vdmj/scheduler/CTMainThread.java | 20 ++++++++++--------- .../vdmj/scheduler/ResourceScheduler.java | 2 +- .../vdmj/scheduler/SchedulablePoolThread.java | 12 ++++++++++- 3 files changed, 23 insertions(+), 11 deletions(-) diff --git a/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/CTMainThread.java b/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/CTMainThread.java index 684b62d37b..78649aa714 100644 --- a/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/CTMainThread.java +++ b/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/CTMainThread.java @@ -29,7 +29,6 @@ import org.overturetool.vdmj.Settings; import org.overturetool.vdmj.commands.DebuggerReader; import org.overturetool.vdmj.lex.LexLocation; -import org.overturetool.vdmj.messages.Console; import org.overturetool.vdmj.runtime.Context; import org.overturetool.vdmj.runtime.ContextException; import org.overturetool.vdmj.statements.Statement; @@ -161,16 +160,19 @@ public void body() } catch (Throwable e) { - if (getException() != null) + if (result.lastIndexOf(Verdict.FAILED) < 0) { - result.add(getException()); - } - else - { - result.add(e.getMessage()); + if (getException() != null) + { + result.add(getException()); + } + else + { + result.add(e.getMessage()); + } + + result.add(Verdict.FAILED); } - - result.add(Verdict.FAILED); } } diff --git a/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/ResourceScheduler.java b/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/ResourceScheduler.java index ff1f3b4943..9f9bc0e16a 100644 --- a/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/ResourceScheduler.java +++ b/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/ResourceScheduler.java @@ -127,7 +127,7 @@ public void start(MainThread main) { try { - Thread.sleep(500); + Thread.sleep(100); } catch (InterruptedException e) { diff --git a/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/SchedulablePoolThread.java b/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/SchedulablePoolThread.java index f95e1f673f..9edf77096c 100644 --- a/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/SchedulablePoolThread.java +++ b/core/vdmj/src/main/java/org/overturetool/vdmj/scheduler/SchedulablePoolThread.java @@ -71,6 +71,16 @@ protected void beforeExecute(Thread t, Runnable r) } } + + @Override + protected void afterExecute(Runnable r, Throwable t) + { + if (r instanceof SchedulablePoolThread) + { + SchedulablePoolThread spt = (SchedulablePoolThread) r; + spt.setThread(null); + } + } /** * Prints an error message if a execution is rejected @@ -464,7 +474,7 @@ public boolean isActive() { return state == RunState.TIMESTEP || state == RunState.WAITING; } - + /* (non-Javadoc) * @see org.overturetool.vdmj.scheduler.ISchedulableThread#isVirtual() */