Add methods to interrupt HandlerPool - #143
Conversation
|
|
||
| private val cellsNotDone = new AtomicReference[Map[Cell[_, _], Queue[SequentialCallbackRunnable[_, _]]]](Map()) // use `values` to store all pending sequential triggers | ||
|
|
||
| private var interruptLatch = new CountDownLatch(1) |
There was a problem hiding this comment.
Should also be @volatile due to assignment on line 466 below.
| t.printStackTrace() | ||
|
|
||
| /** | ||
| * Interrupt the computation of cells. It can be resumed using the `resume` method. |
| def resume(): Unit = { | ||
| isInterrupted = false | ||
| interruptLatch.countDown() | ||
| interruptLatch = new CountDownLatch(1) |
There was a problem hiding this comment.
Would it simplify finding bugs if this method would throw an exception (e.g., IllegalStateException) in case it is attempted to resume a non-interrupted pool?
There was a problem hiding this comment.
In the PropertyStore the interrupt is implemented as @volatile var isInterrupted: () ⇒ Boolean. Therefore I call resume every time the client waits for quiescense, which should resume the store if it was interrupted.
|
|
||
| assert(cell2.getResult() == 0) | ||
|
|
||
| pool.resume() |
There was a problem hiding this comment.
I think it would be good to add a test case where more than one task is interrupted. Also, there should be a test case, where only one of two tasks is interrupted, because the interrupt is too late for the first task.
| /** | ||
| * Interrupt the computation of cells. It can be resumed using the `resume` method. | ||
| */ | ||
| def interrupt(): Unit = { |
There was a problem hiding this comment.
"interrupt" -> "suspend". The pair suspend/resume is much more common. Moreover, interrupt already has a different meaning for threads on the JVM (including InterruptedException etc.), so it is actually quite confusing to call this method interrupt!
There was a problem hiding this comment.
Changed to suspend.
0c2c4c6 to
56072a0
Compare
|
I applied your requested changes. Once test fails, because the |
No description provided.