private static boolean emitEvents ( WatchService watchService , Subscriber < ? super WatchEvent < ? > > subscriber , long pollDurationMs , long pollIntervalMs ) { // get the first event WatchKey key = nextKey ( watchService , subscriber , pollDurationMs ) ; if ( key != null ) { if ( subscriber . isUnsubscribed ( ) ) return false ; // we have a polled event, now we traverse it and // receive all the states from it for ( WatchEvent < ? > event : key . pollEvents ( ) ) { if ( subscriber . isUnsubscribed ( ) ) return false ; else subscriber . onNext ( event ) ; } boolean valid = key . reset ( ) ; if ( ! valid && ! subscriber . isUnsubscribed ( ) ) { subscriber . onCompleted ( ) ; return false ; } else if ( ! valid ) return false ; } return true ; }
returns true if and only there may be more events