ignite-notifications mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From GitBox <...@apache.org>
Subject [GitHub] [ignite] AMashenkov commented on a change in pull request #6839: IGNITE-11815: replace GridTestUtils.retryAssert with GridTestUtils.waitForCondition
Date Tue, 24 Sep 2019 15:07:34 GMT
AMashenkov commented on a change in pull request #6839: IGNITE-11815: replace GridTestUtils.retryAssert
with GridTestUtils.waitForCondition
URL: https://github.com/apache/ignite/pull/6839#discussion_r327671322
 
 

 ##########
 File path: modules/core/src/test/java/org/apache/ignite/testframework/GridTestUtils.java
 ##########
 @@ -1798,6 +1766,35 @@ public static boolean waitForCondition(GridAbsPredicate cond, long
timeout) thro
         return false;
     }
 
+    /**
+     * Waits until given condition is met or timeout. Exception free check. Polling in busy
wait loop is used.
+     *
+     * @param cond condition to met.
+     * @param timeout max time to wait in milliseconds.
+     * @return {@code true} if condition was met, {@code false} otherwise or in case of timeout/exception.
+     */
+    public static boolean waitUntil(Supplier<Boolean> cond, long timeout) {
+        assert timeout > 0;
+        long curTime = U.currentTimeMillis();
+        long endTime = curTime + timeout;
+
+        try {
+            while (curTime < endTime) {
+                if (cond.get()) {
 
 Review comment:
   Code style convention does't allow braces for one-liner.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services

Mime
View raw message