service-registry-curator/src/main/java/com/rackspacecloud/client/service_registry/curator/RSRServiceCacheImpl.java
private void pollAndProcessEvents() {
        MethodOptions options = new MethodOptions(100, null);
        List<Event> events = null;
        int count = 0;
        do {
            if (shouldStopPolling) break;
            count += 1;
            try {
                // get events from server, filter the ones we are interested in.
                events = Lists.newArrayList(discovery.getClient().getEventsClient().list(options));
                String lastEventId = processEvents(events);
                options = options.withMarker(lastEventId);
            } catch (Exception ex) {
                // todo: just log it.
                events = null;
            }
        } while (events != null && events.size() > 0);
        
        // if it only happened once, assume there are not many events happening.
        if (count == 1) {
            // todo: trace message.
            // todo: this should become configurable.
            try { Thread.sleep(1000); } catch (Exception ex) {}
        }
    }
private void pollAndProcessEvents() {
        MethodOptions options = new MethodOptions(100, null);
        List<Event> events = null;
        int count = 0;
        do {
            if (shouldStopPolling) break;
            count += 1;
            try {
                // get events from server, filter the ones we are interested in.
                events = Lists.newArrayList(discovery.getClient().getEventsClient().list(options));
                String lastEventId = processEvents(events);
                options = options.withMarker(lastEventId);
            } catch (Exception ex) {
                // todo: just log it.
                events = null;
            }
        } while (events != null && events.size() > 0);
        
        // if it only happened once, assume there are not many events happening.
        if (count == 1) {
            // todo: trace message.
            // todo: this should become configurable.
            try { Thread.sleep(1000); } catch (Exception ex) {}
        }
    }
todo: switch to iterator.