public void testBasicCallable() { CloseableExecutorService service = new CloseableExecutorService(executorService); CountdownEvent startLatch = new CountdownEvent(QTY); CountdownEvent latch = new CountdownEvent(QTY); for (int i = 0; i < QTY; i++) { submitJoinRunnable(service, startLatch, latch); } Assert.True(startLatch.Wait(TimeSpan.FromSeconds(15))); service.Dispose(); Assert.True(latch.Wait(TimeSpan.FromSeconds(15))); }
public void testPartialRunnable() { CountdownEvent outsideLatch = new CountdownEvent(1); executorService.submit ( new FutureTask <object>(CallableUtils.FromFunc <object>(() => { try { Thread.CurrentThread.Join(); } finally { outsideLatch.Signal(); } return(null); })) ); CloseableExecutorService service = new CloseableExecutorService(executorService); CountdownEvent startLatch = new CountdownEvent(QTY); CountdownEvent latch = new CountdownEvent(QTY); for (int i = 0; i < QTY; ++i) { submitRunnable(service, startLatch, latch); } while (service.size() < QTY) { Thread.Sleep(100); } Assert.True(startLatch.Wait(TimeSpan.FromSeconds(15))); service.Dispose(); Assert.True(latch.Wait(TimeSpan.FromSeconds(15))); Assert.AreEqual(1, outsideLatch.CurrentCount); }
public void testBasicRunnable() { try { CloseableExecutorService service = new CloseableExecutorService(executorService); CountdownEvent startLatch = new CountdownEvent(QTY); CountdownEvent latch = new CountdownEvent(QTY); for (int i = 0; i < QTY; i++) { submitRunnable(service, startLatch, latch); } Assert.True(startLatch.Wait(TimeSpan.FromSeconds(15))); service.Dispose(); Assert.True(latch.Wait(TimeSpan.FromSeconds(15))); } catch (AssertionException e) { throw e; } catch (Exception e) { Console.WriteLine(e.ToString()); } }
public void testBasicRunnable() { try { CloseableExecutorService service = new CloseableExecutorService(executorService); CountdownEvent startLatch = new CountdownEvent(QTY); CountdownEvent latch = new CountdownEvent(QTY); for (int i = 0; i < QTY; i++) { submitRunnable(service, startLatch, latch); } Assert.True(startLatch.Wait(TimeSpan.FromSeconds(15))); service.Dispose(); Assert.True(latch.Wait(TimeSpan.FromSeconds(15))); } catch ( AssertionException e ) { throw e; } catch ( Exception e ) { Console.WriteLine(e.ToString()); } }
public void testPartialRunnable() { CountdownEvent outsideLatch = new CountdownEvent(1); executorService.submit ( new FutureTask<object>(CallableUtils.FromFunc<object>(() => { try { Thread.CurrentThread.Join(); } finally { outsideLatch.Signal(); } return null; })) ); CloseableExecutorService service = new CloseableExecutorService(executorService); CountdownEvent startLatch = new CountdownEvent(QTY); CountdownEvent latch = new CountdownEvent(QTY); for ( int i = 0; i<QTY; ++i ) { submitRunnable(service, startLatch, latch); } while ( service.size() < QTY ) { Thread.Sleep(100); } Assert.True(startLatch.Wait(TimeSpan.FromSeconds(15))); service.Dispose(); Assert.True(latch.Wait(TimeSpan.FromSeconds(15))); Assert.AreEqual(1, outsideLatch.CurrentCount); }