nd4j-backends/nd4j-backend-impls/nd4j-cuda/src/main/java/org/nd4j/jita/allocator/concurrency/AtomicState.java
public void requestTick(long time, TimeUnit timeUnit) {
        long timeframeMs = TimeUnit.MILLISECONDS.convert(time, timeUnit);
        long currentTime = System.currentTimeMillis();
        boolean isWaiting = false;

        // if we have Toe request queued - we' have to wait till it finishes.
        try {
            while (isToeScheduled.get() || isToeWaiting.get() || getCurrentState() == AccessState.TOE) {
                if (!isWaiting) {
                    isWaiting = true;
                    waitingTicks.incrementAndGet();
                }
                Thread.sleep(50);
            }

            currentState.set(AccessState.TICK.ordinal());
            waitingTicks.decrementAndGet();
            tickRequests.incrementAndGet();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
public void requestTick(long time, TimeUnit timeUnit) {
        long timeframeMs = TimeUnit.MILLISECONDS.convert(time, timeUnit);
        long currentTime = System.currentTimeMillis();
        boolean isWaiting = false;

        // if we have Toe request queued - we' have to wait till it finishes.
        try {
            while (isToeScheduled.get() || isToeWaiting.get() || getCurrentState() == AccessState.TOE) {
                if (!isWaiting) {
                    isWaiting = true;
                    waitingTicks.incrementAndGet();
                }
                Thread.sleep(50);
            }

            currentState.set(AccessState.TICK.ordinal());
            waitingTicks.decrementAndGet();
            tickRequests.incrementAndGet();
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
This method requests to change state to Tick.

PLEASE NOTE: this method is blocking, if memory is in Toe state.
PLEASE NOTE: if Tick can't be acquired within specified timeframe, exception will be thrown

@param time
@param timeUnit