All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.agroal.test.AgroalTestHelper Maven / Gradle / Ivy

There is a newer version: 2.5
Show newest version
// Copyright (C) 2017 Red Hat, Inc. and individual contributors as indicated by the @author tags.
// You may not use this file except in compliance with the Apache License, Version 2.0.

package io.agroal.test;

import java.time.Duration;

import static java.lang.System.nanoTime;
import static java.lang.Thread.sleep;

/**
 * @author Luis Barreiro
 */
public class AgroalTestHelper {

    private AgroalTestHelper() {
    }

    public static void safeSleep(Duration duration) {
        long target = nanoTime() + duration.toNanos();
        do {
            try {
                sleep( duration.toMillis() );
            } catch ( InterruptedException e ) {
                // retry
            }
        } while ( nanoTime() < target );
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy