Window { public WindowFuture offer(K key, R request, long offerTimeoutMillis) throws DuplicateKeyException, OfferTimeoutException, InterruptedException { return this.offer(key, request, offerTimeoutMillis, -1, false); } Window(int size);  Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener);  Window(int size, ScheduledExecutorService executor, long monitorInterval, WindowListener<K,R,P> listener, String monitorThreadName); int getMaxSize(); int getSize(); int getFreeSize(); boolean containsKey(K key); WindowFuture<K,R,P> get(K key); void addListener(WindowListener<K,R,P> listener); void removeListener(WindowListener<K,R,P> listener); synchronized void destroy(); synchronized boolean startMonitor(); synchronized void stopMonitor(); Map<K,WindowFuture<K,R,P>> createSortedSnapshot(); WindowFuture offer(K key, R request, long offerTimeoutMillis); WindowFuture offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis); WindowFuture offer(K key, R request, long offerTimeoutMillis, long expireTimeoutMillis, boolean callerWaitingHint); int getPendingOfferCount(); boolean abortPendingOffers(); WindowFuture<K,R,P> complete(K key, P response); WindowFuture<K,R,P> fail(K key, Throwable t); List<WindowFuture<K,R,P>> failAll(Throwable t); WindowFuture<K,R,P> cancel(K key); List<WindowFuture<K,R,P>> cancelAll(); List<WindowFuture<K,R,P>> cancelAllExpired();  }
@Test public void awaitTimesout() throws Exception { Window<Integer,String,String> window = new Window<Integer,String,String>(1); WindowFuture<Integer,String,String> requestFuture0 = window.offer(0, "Request0", 100); Assert.assertFalse(requestFuture0.await(100)); }
@Test public void waitingFlagNotOriginallySetButAddedOnAwait() throws Exception { Window<Integer,String,String> window = new Window<Integer,String,String>(1); WindowFuture<Integer,String,String> requestFuture0 = window.offer(0, "Request0", 100); Assert.assertEquals(WindowFuture.CALLER_NOT_WAITING, requestFuture0.getCallerStateHint()); Assert.assertFalse(requestFuture0.isCallerWaiting()); Assert.assertFalse(requestFuture0.await(30)); Assert.assertEquals(WindowFuture.CALLER_WAITING_TIMEOUT, requestFuture0.getCallerStateHint()); }