Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test to prevent doing a blocking input table edit from a thread t…
Browse files Browse the repository at this point in the history
…hat holds the update graph's shared lock.

Correct test for async edits to use the right update graph.
rcaudy committed Jun 7, 2024
1 parent bf13489 commit 0398862
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -306,18 +306,23 @@ private void checkBlockingEditSafety() {
if (updateGraph.currentThreadProcessesUpdates()) {
throw new UnsupportedOperationException("Attempted to make a blocking input table edit from a listener "
+ "or notification. This is unsupported, because it will block the update graph from making "
+ "progress.");
+ "progress and hang indefinitely.");
}
if (updateGraph.sharedLock().isHeldByCurrentThread()) {
throw new UnsupportedOperationException("Attempted to make a blocking input table edit while holding "
+ "the update graph's shared lock. This is unsupported, because it will block the update graph "
+ "from making progress and hang indefinitely.");
}
}

private void checkAsyncEditSafety(@NotNull final Table changeData) {
if (changeData.isRefreshing()
&& updateGraph.currentThreadProcessesUpdates()
&& !changeData.satisfied(updateGraph.clock().currentStep())) {
&& changeData.getUpdateGraph().currentThreadProcessesUpdates()
&& !changeData.satisfied(changeData.getUpdateGraph().clock().currentStep())) {
throw new UnsupportedOperationException("Attempted to make an asynchronous input table edit from a "
+ "listener or notification before the change data table is satisfied on the current cycle. "
+ "This is unsupported, because it may block the update graph from making progress or produce "
+ "inconsistent results.");
+ "listener or notification before the table of data to add or delete is satisfied on the "
+ "current cycle. This is unsupported, because it may block the update graph from making "
+ "progress or produce inconsistent results.");
}
}

0 comments on commit 0398862

Please sign in to comment.