jdeppe-pivotal commented on a change in pull request #6794:
URL: https://github.com/apache/geode/pull/6794#discussion_r698810683
##########
File path:
geode-apis-compatible-with-redis/src/commonTest/java/org/apache/geode/redis/ConcurrentLoopingThreads.java
##########
@@ -84,18 +86,49 @@ public void await() {
* Start operations and only return once all are complete.
*/
public void run() {
- start(false);
+ start(false, null);
await();
}
/**
* Start operations and run each iteration in lockstep
*/
public void runInLockstep() {
- start(true);
+ start(true, null);
await();
}
+ /**
+ * Start operations and provide an action to be performed at the end of
every iteration. This
+ * implies running in lockstep. This would typically be used to provide some
form of validation.
+ */
+ public void runWithAction(Runnable action) {
+ Runnable innerRunnable = () -> {
+ try {
+ action.run();
+ } catch (Throwable e) {
+ actionThrowable.set(e);
+ throw e;
+ }
+ };
+
+ start(true, innerRunnable);
+
+ try {
+ await();
+ } catch (Throwable e) {
+ Throwable actionException = actionThrowable.get();
+ if (actionException != null) {
+ if (actionException instanceof Error) {
+ throw (Error) actionException;
+ }
+ throw new RuntimeException(actionThrowable.get());
Review comment:
Good point. I think I was initially trying to set this elsewhere but now
I've removed the `AtomicReference` wrapper since it can just be a regular field.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]