319320321322323324325326327328329
Thread.sleep(200); channel1.send("hello"); fib.join(); } @Test public void testSelectSend1() throws Exception { final Channel<String> channel1 = newChannel();
355356357358359360361362363364365
Thread.sleep(200); String m2 = channel1.receive(); assertThat(m2, equalTo("hi1")); fib.join(); } @Test public void testSelectSend2() throws Exception { final Channel<String> channel1 = newChannel();
390391392393394395396397398399400
assertThat(m1, equalTo("hi2")); String m2 = channel1.receive(); assertThat(m2, equalTo("hi1")); fib.join(); } @Test public void testSelectSendWithClose1() throws Exception { final Channel<String> channel1 = newChannel();
421422423424425426427428429430431
Thread.sleep(200); channel2.close(); fib.join(); } @Test public void testSelectSendWithClose2() throws Exception { final Channel<String> channel1 = newChannel();
453454455456457458459460461462463
}).start(); channel2.close(); fib.join(); } @Test public void testSelectSendTimeout() throws Exception { final Channel<String> channel1 = newChannel();
486487488489490491492493494495496
String m1 = channel3.receive(); assertThat(m1, equalTo("bye3")); // the first send is cancelled fib.join(); } @Test public void testSelectSendWithTimeoutChannel() throws Exception { final Channel<String> channel1 = newChannel();
521522523524525526527528
String m1 = channel3.receive(); assertThat(m1, equalTo("bye3")); // the first send is cancelled fib.join(); } }
121122123124125126127128129130131
System.out.println("f1: " + f1); f2.join(); System.out.println("f2: " + f2); f3.join(); System.out.println("f3: " + f3); f4.join(); System.out.println("f4: " + f4); t1.join(); System.out.println("t1: " + t1); t2.join(); System.out.println("t2: " + t2);
251252253254255256257258259260261
ch.close(); } }).start(); fib1.join(); fib2.join(); } @Test public void testFilterThreadToFiber() throws Exception { final Channel<Integer> ch = newChannel();
287288289290291292293294295296297
ch.send(3); ch.send(4); ch.send(5); ch.close(); fib.join(); } @Test public void testFilterFiberToThread() throws Exception { final Channel<Integer> ch = newChannel();