Skip to content

Commit

Permalink
Fixed RejectedExecution
Browse files Browse the repository at this point in the history
Fixed Validition.Philosophers resolving promise twice.
Fixed RejectedExecutionException when sending messages while shutting down, throw ThreadDeath instead.
  • Loading branch information
daumayr committed Jan 23, 2017
1 parent 2a82815 commit 988efea
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
10 changes: 7 additions & 3 deletions core-lib/Benchmarks/Validation.som
Original file line number Diff line number Diff line change
Expand Up @@ -397,6 +397,7 @@ class Validation usingPlatform: platform andHarness: harness = Value (
private numExitedPhilosophers ::= 0.
private resolver = resolver.
private abortion ::= false.
private resolved ::= false.
|)(
public hungry: philosopher id: leftForkId = (
| rightForkId |
Expand Down Expand Up @@ -426,13 +427,16 @@ class Validation usingPlatform: platform andHarness: harness = Value (
| forksTaken |
forksTaken := 0.
forks do: [:f | f ifTrue: [ forksTaken := forksTaken + 1 ] ].

resolver resolve: 0 ]
resolved ifFalse:[
resolved := true.
resolver resolve: 0]]
)

public abort = (
abortion := true.
resolver resolve: 1.
resolved ifFalse:[
resolved := true.
resolver resolve: 1]
)
)

Expand Down
7 changes: 6 additions & 1 deletion src/som/interpreter/actors/Actor.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.concurrent.ForkJoinPool;
import java.util.concurrent.ForkJoinPool.ForkJoinWorkerThreadFactory;
import java.util.concurrent.ForkJoinWorkerThread;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicInteger;

Expand Down Expand Up @@ -295,7 +296,11 @@ private boolean getCurrentMessagesOrCompleteExecution() {

@TruffleBoundary
private void executeOnPool() {
actorPool.execute(executor);
try {
actorPool.execute(executor);
} catch (RejectedExecutionException e) {
throw new ThreadDeath();
}
}

/**
Expand Down

0 comments on commit 988efea

Please sign in to comment.