A reactor is a light-weight thread dedicated to processing requests and responses (requests with a response value).
A reactor has an input queue of requests/responses not yet processed and a table of requests/responses to be sent to other reactors.
910111213141516171819
import org.agilewiki.jactor2.core.requests.BoundResponseProcessor; import org.agilewiki.jactor2.core.requests.impl.AsyncRequestImpl; public class BoundResponseProcessorTest extends CallTestBase { public void test() throws Exception { new Plant(); try { final Driver driver = new Driver(); Assert.assertEquals("Hello world!", call(driver.doitAOp())); } finally { Plant.close();
6789101112131415
/** * Test code. */ public class Test3 extends CallTestBase { public void testb() throws Exception { new Plant(); final Blade3 blade3 = new Blade3(); call(blade3.hi3SOp()); Plant.close(); }
7891011121314151617
/** * Test code. */ public class Test1 extends CallTestBase { public void testa() throws Exception { new Plant(); final IsolationReactor reactor = new IsolationReactor(); final Blade11 blade1 = new Blade11(reactor); final String result = call(blade1.hiSOp()); assertEquals("Hello world!", result); Plant.close();
import org.agilewiki.jactor2.core.requests.AsyncResponseProcessor; import org.agilewiki.jactor2.core.requests.impl.AsyncRequestImpl; public class ICloseTest extends CallTestBase { public void testa() throws Exception { new Plant(); try { call(new IHang().goAOp()); //} catch (ReactorClosedException e) { } finally { Plant.close();
1415161718192021222324
public class IsolationTest extends CallTestBase { public void test1() throws Exception { Thread.sleep(100); System.err.println("\ntest 1"); new Plant(); try { Foot foot = new Foot(new IsolationReactor()); assertTrue(call(foot.dAOp())); } finally { Plant.close();
2627282930313233343536
} public void test2() throws Exception { Thread.sleep(100); System.err.println("\ntest 2"); new Plant(); try { Foot foot = new Foot(new IsolationReactor()); Via via = new Via(foot.dAOp()); assertTrue(call(via.dAOp())); } finally {
3940414243444546474849
} public void test3() throws Exception { Thread.sleep(100); System.err.println("\ntest 3"); new Plant(); try { Foot foot = new Foot(new IsolationReactor()); Head head = new Head(foot.dAOp()); System.err.println("skipping this test"); //assertFalse(call(head.dAOp()));
5354555657585960616263
} public void test4() throws Exception { Thread.sleep(100); System.err.println("\ntest 4"); new Plant(); try { Foot foot = new Foot(new IsolationReactor()); Via via = new Via(foot.dAOp()); Head head = new Head(via.dAOp()); System.err.println("skipping this test");
6869707172737475767778
} public void test5() throws Exception { Thread.sleep(100); System.err.println("\ntest 5"); new Plant(); try { IsolationReactor reactor = new IsolationReactor(); Foot foot = new Foot(reactor); Via via = new Via(foot.dAOp()); Head head = new Head(via.dAOp(), reactor);
8384858687888990919293
} public void test6() throws Exception { Thread.sleep(100); System.err.println("\ntest 6"); new Plant(); try { IsolationReactor reactor = new IsolationReactor(); Foot foot = new Foot(reactor); Head head = new Head(foot.dAOp(), reactor); assertTrue(call(head.dAOp()));