Example usage for io.vertx.core.impl NoStackTraceThrowable NoStackTraceThrowable

List of usage examples for io.vertx.core.impl NoStackTraceThrowable NoStackTraceThrowable

Introduction

In this page you can find the example usage for io.vertx.core.impl NoStackTraceThrowable NoStackTraceThrowable.

Prototype

public NoStackTraceThrowable(String message) 

Source Link

Usage

From source file:io.reactiverse.pgclient.impl.ConnectionPool.java

License:Apache License

private void check() {
    if (closed) {
        return;/* w w w  .j a  v  a2 s .c  o m*/
    }
    if (!checkInProgress) {
        checkInProgress = true;
        try {
            while (waiters.size() > 0) {
                if (available.size() > 0) {
                    PooledConnection proxy = available.poll();
                    Future<Connection> waiter = waiters.poll();
                    waiter.complete(proxy);
                } else {
                    if (size < maxSize) {
                        Future<Connection> waiter = waiters.poll();
                        size++;
                        connector.accept(ar -> {
                            if (ar.succeeded()) {
                                Connection conn = ar.result();
                                PooledConnection proxy = new PooledConnection(conn);
                                all.add(proxy);
                                conn.init(proxy);
                                waiter.complete(proxy);
                            } else {
                                size--;
                                waiter.fail(ar.cause());
                                check();
                            }
                        });
                    } else {
                        if (maxWaitQueueSize >= 0) {
                            int numInProgress = size - all.size();
                            int numToFail = waiters.size() - (maxWaitQueueSize + numInProgress);
                            while (numToFail-- > 0) {
                                Future<Connection> waiter = waiters.pollLast();
                                waiter.fail(new NoStackTraceThrowable("Max waiter size reached"));
                            }
                        }
                        break;
                    }
                }
            }
        } finally {
            checkInProgress = false;
        }
    }
}