/*
 * Copyright 2014-2017 Real Logic Ltd.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.aeron;

import java.util.function.BooleanSupplier;
import java.util.function.IntConsumer;

public class SystemTestHelper
{
    public static void executeUntil(
        final BooleanSupplier condition, final IntConsumer consumer, final int maxIterations, final long timeout)
    {
        final long start = System.nanoTime();
        long end;
        int iteration = 0;

        do
        {
            consumer.accept(iteration);
            end = System.nanoTime();
        }
        while (!condition.getAsBoolean() && ((end - start) < timeout) && iteration++ < maxIterations);
    }
}

@@ -727,16 +727,380 @@
 elper%0A%7B%0A
+    /**%0A     * Execute a task until a condition is satisfied, or a maximum number of iterations, or a timeout is reached.%0A     *%0A     * @param condition         keep executing while true.%0A     * @param iterationConsumer to be invoked with the iteration count.%0A     * @param maxIterations     to be executed.%0A     * @param timeoutNs         to stay within.%0A     */%0A
     publ
@@ -1168,16 +1168,24 @@
 ndition,
+%0A       
  final I
@@ -1199,17 +1199,34 @@
 mer 
-consumer,
+iterationConsumer,%0A       
  fin
@@ -1246,16 +1246,24 @@
 rations,
+%0A       
  final l
@@ -1273,16 +1273,18 @@
  timeout
+Ns
 )%0A    %7B%0A
@@ -1307,16 +1307,18 @@
 ng start
+Ns
  = Syste
@@ -1344,19 +1344,21 @@
    long 
-end
+nowNs
 ;%0A      
@@ -1364,24 +1364,16 @@
    int i
-teration
  = 0;%0A%0A 
@@ -1404,17 +1404,26 @@
         
-c
+iterationC
 onsumer.
@@ -1430,24 +1430,16 @@
 accept(i
-teration
 );%0A     
@@ -1445,19 +1445,21 @@
         
-end
+nowNs
  = Syste
@@ -1532,19 +1532,21 @@
 & ((
-end
+nowNs
  - start
 ) %3C 
@@ -1541,16 +1541,18 @@
  - start
+Ns
 ) %3C time
@@ -1558,22 +1558,16 @@
 eout
+Ns
 ) && i
-teration
 ++ %3C

Add javadoc to SystemTestHelper