private synchronized boolean internalEnter()

in curator-recipes/src/main/java/org/apache/curator/framework/recipes/barriers/DistributedDoubleBarrier.java [255:287]


    private synchronized boolean internalEnter(long startMs, boolean hasMaxWait, long maxWaitMs) throws Exception {
        boolean result = true;
        do {
            List<String> children = getChildrenForEntering();
            int count = (children != null) ? children.size() : 0;
            if (count >= memberQty) {
                try {
                    client.create().forPath(readyPath);
                } catch (KeeperException.NodeExistsException ignore) {
                    // ignore
                }
                break;
            }

            if (hasMaxWait && !hasBeenNotified.get()) {
                long elapsed = System.currentTimeMillis() - startMs;
                long thisWaitMs = maxWaitMs - elapsed;
                if (thisWaitMs <= 0) {
                    result = false;
                } else {
                    wait(thisWaitMs);
                }

                if (!hasBeenNotified.get()) {
                    result = false;
                }
            } else {
                wait();
            }
        } while (false);

        return result;
    }