/*
(non-Javadoc)
@see org.redisson.core.RBlockingQueue#pollFromAny(long, java.util.concurrent.TimeUnit, java.lang.String[])
436146
@Override
    public V pollFromAny(long timeout, TimeUnit unit, String... queueNames) throws InterruptedException {
        return get(pollFromAnyAsync(timeout, unit, queueNames));
    }
1200089
protected void updateLockHolder(String clientId, long lockDurationMs) {
        this.clientId = clientId;
        this.timestampExpiry = System.currentTimeMillis() + lockDurationMs;
    }
974361
public PollingWait pollEvery(long timeAmount, @Nonnull TimeUnit timeUnit) {
        if (timeAmount <= 0) {
            throw new IllegalArgumentException("Invalid timeAmount: " + timeAmount + " -- must be greater than 0");
        }
        pollIntervalMillis = timeUnit.toMillis(timeAmount);
        return this;
    }
786349
public boolean await(long timeout, TimeUnit unit) {
        try {
            return latch.await(timeout, unit);
        } catch (InterruptedException e) {
            throw new RedisCommandInterruptedException(e);
        }
    }
1321578
@SuppressWarnings("unchecked")
    @Override
    public E poll() {
        if (_size.get() == 0)
            return null;

        E e = null;

        _headLock.lock(); // Size cannot shrink
        try {
            if (_size.get() > 0) {
                final int head = _indexes[HEAD_OFFSET];
                e = (E) _elements[head];
                _elements[head] = null;
                _indexes[HEAD_OFFSET] = (head + 1) % _elements.length;
                if (_size.decrementAndGet() > 0)
                    _notEmpty.signal();
            }
        } finally {
            _headLock.unlock();
        }
        return e;
    }
708978
public E poll() {
        final ReentrantLock lock = this.lock;
        lock.lock();
        try {
            E first = q.peek();
            return (first == null || first.getDelay(NANOSECONDS) > 0)
                ? null
                : q.poll();
        } finally {
            lock.unlock();
        }
    }
365439
@Override
    public E poll() {
        final long consumerIndex = lvConsumerIndex(); // LoadLoad
        final int offset = calcElementOffset(consumerIndex);
        // Copy field to avoid re-reading after volatile load
        final AtomicReferenceArray<E> buffer = this.buffer;

        // If we can't see the next available element we can't poll
        E e = lvElement(buffer, offset); // LoadLoad
        if (null == e) {
            /*
             * NOTE: Queue may not actually be empty in the case of a producer (P1) being interrupted after
             * winning the CAS on offer but before storing the element in the queue. Other producers may go on
             * to fill up the queue after this element.
             */
            if (consumerIndex != lvProducerIndex()) {
                do {
                    e = lvElement(buffer, offset);
                } while (e == null);
            } else {
                return null;
            }
        }

        spElement(buffer, offset, null);
        soConsumerIndex(consumerIndex + 1); // StoreStore
        return e;
    }
299930
def poll(self, timeout):
        
        timeout = float(timeout)
        end_time = time.time() + timeout
        while True:
            # Keep reading until data is received or timeout
            incoming = self.stream.read(self._max_read)
            if incoming:
                return incoming
            if (end_time - time.time()) < 0:
                raise ExpectTimeout()
            time.sleep(self._poll_period)
162585
public static void longpoll(DbxAuthInfo auth, String path) throws IOException {
        long longpollTimeoutSecs = TimeUnit.MINUTES.toSeconds(2);

        // need 2 Dropbox clients for making calls:
        //
        // (1) One for longpoll requests, with its read timeout set longer than our polling timeout
        // (2) One for all other requests, with its read timeout set to the default, shorter timeout
        //
        StandardHttpRequestor.Config config = StandardHttpRequestor.Config.DEFAULT_INSTANCE;
        StandardHttpRequestor.Config longpollConfig = config.copy()
            // read timeout should be greater than our longpoll timeout and include enough buffer
            // for the jitter introduced by the server. The server will add a random amount of delay
            // to our longpoll timeout to avoid the stampeding herd problem. See
            // DbxFiles.listFolderLongpoll(String, long) documentation for details.
            .withReadTimeout(5, TimeUnit.MINUTES)
            .build();

        DbxClientV2 dbxClient = createClient(auth, config);
        DbxClientV2 dbxLongpollClient = createClient(auth, longpollConfig);

        try {
            // We only care about file changes, not existing files, so grab latest cursor for this
            // path and then longpoll for changes.
            String cursor = getLatestCursor(dbxClient, path);

            System.out.println("Longpolling for changes... press CTRL-C to exit.");
            while (true) {
                // will block for longpollTimeoutSecs or until a change is made in the folder
                ListFolderLongpollResult result = dbxLongpollClient.files()
                    .listFolderLongpoll(cursor, longpollTimeoutSecs);

                // we have changes, list them
                if (result.getChanges()) {
                    cursor = printChanges(dbxClient, cursor);
                }

                // we were asked to back off from our polling, wait the requested amount of seconds
                // before issuing another longpoll request.
                Long backoff = result.getBackoff();
                if (backoff != null) {
                    try {
                        System.out.printf("backing off for %d secs...\n", backoff.longValue());
                        Thread.sleep(TimeUnit.SECONDS.toMillis(backoff));
                    } catch (InterruptedException ex) {
                        System.exit(0);
                    }
                }
            }
        } catch (DbxApiException ex) {
            // if a user message is available, try using that instead
            String message = ex.getUserMessage() != null ? ex.getUserMessage().getText() : ex.getMessage();
            System.err.println("Error making API call: " + message);
            System.exit(1);
        } catch (NetworkIOException ex) {
            System.err.println("Error making API call: " + ex.getMessage());
            if (ex.getCause() instanceof SocketTimeoutException) {
                System.err.println("Consider increasing socket read timeout or decreasing longpoll timeout.");
            }
            System.exit(1);
        } catch (DbxException ex) {
            System.err.println("Error making API call: " + ex.getMessage());
            System.exit(1);
        }
    }
1184813
public boolean withEveryRetryWaitFor(int time, TimeUnit units) {
        for (int i = 1; i <= retries; i++) {
            if (openSocket()) {
                return true;
            }
            sleepFor(time, units);
        }
        return false;
    }
500945
function (method, path, propertyString, check, valueString, done) {
        this._log.info('Step: I poll with a %s request to %s until %s %s %s',
                       method, path, propertyString, check, valueString);
        var testConfig = this.testConfig || {};
        var pollConfig = testConfig.polling || {};
        var duration = pollConfig.durationMs || 5000;
        var interval = pollConfig.intervalMs || 1000;
        var maxRetries = Math.floor(duration / interval);
        var _this = this;
        async.retry(maxRetries, poll, done);
        function poll(callback) {
            var currentChecker = checkResult.bind(null, callback);
            setTimeout(makeRequest.bind(_this, method, path, currentChecker), interval);
        }
        function checkResult(callback) {
            try {
                _this._checkProperty(propertyString, check, valueString);
            } catch(err) {
                _this._log.trace({ err: err }, 'Condition not yet met, continue polling.');
                return callback(err);
            }
            return callback();
        }
    }
988190
public PollingWait timeoutAfter(long timeAmount, @Nonnull TimeUnit timeUnit) {
        if (timeAmount <= 0) {
            throw new IllegalArgumentException("Invalid timeAmount: " + timeAmount + " -- must be greater than 0");
        }
        timeoutMillis = timeUnit.toMillis(timeAmount);
        return this;
    }
528991
protected int poll(final Selector selector, final long tout, final Collection<zmq.poll.PollItem> items)
    {
        final int size = items.size();
        return zmq.ZMQ.poll(selector, items.toArray(new PollItem[size]), size, tout);
    }
1310068
public void setPollInterval( long pollInterval ) {

		this.pollInterval = pollInterval;
		this.logger.fine( "Template watcher poll interval set to " + pollInterval );
		synchronized( this.watcherLock ) {
			if( this.templateWatcher != null )
				resetWatcher();
		}
	}
730342
def _pulse_poll(self, timeout=None):
		''''''
		with self._pulse_loop() as loop:
			ts = c.mono_time()
			ts_deadline = timeout and (ts + timeout)
			while True:
				delay = max(0, int((ts_deadline - ts) * 1000000)) if ts_deadline else -1
				c.pa.mainloop_prepare(loop, delay) # usec
				c.pa.mainloop_poll(loop)
				if self._loop_closed: break # interrupted by close() or such
				c.pa.mainloop_dispatch(loop)
				if self._loop_stop: break
				ts = c.mono_time()
				if ts_deadline and ts >= ts_deadline: break
80332
@Override
    public V poll(long timeout, TimeUnit unit) throws InterruptedException {
        return get(pollAsync(timeout, unit));
    }
389841
public synchronized void setPollingInterval(final long pollingInterval) {
        if (pollingInterval <= 0) {
            throw new IllegalArgumentException("'pollingInterval' must be greater than 0");
        }

        currentPollingInterval = pollingInterval;

        if (listeners.size() > 0) {
            stop();
            start();
        }
    }