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.
6061626364656667686970
} }; } public static void main(final String[] _args) throws Exception { new Plant(); try { final Account account1 = new Account(); account1.depositSOp(1000).call(); final Account account2 = new Account(); System.out.println(account1.transferAOp(500, account2).call());
1314151617181920212223
public class ExceptionHandlerSample { public static void main(final String[] _args) throws Exception { //A facility with two threads. new Plant(2); try { //Create an ExceptionBlade. ExceptionBlade exceptionBlade = new ExceptionBlade(new NonBlockingReactor());
101112131415161718
import javax.swing.*; public class SwingBoundReactorSample { public static void main(final String[] _args) throws Exception { //Create a plant with 5 threads. Plant plant = new Plant(5); new HelloWorld(new SwingBoundReactor()).createAndShowAOp().signal(); }
1011121314151617181920
public class RequestSample { public static void main(String[] args) throws Exception { //A facility with two threads. new Plant(2); try { //Create blades. SampleBlade2 bladeA = new SampleBlade2(new NonBlockingReactor());
678910111213141516
import org.agilewiki.jactor2.core.requests.AsyncResponseProcessor; import org.agilewiki.jactor2.core.requests.impl.AsyncRequestImpl; public class Simple { public static void main(final String[] _args) throws Exception { new Plant(); try { A a = new A(); a.startAOp().call(); } finally { Plant.close();
910111213141516171819
public class ThreadBoundReactorSample { public static void main(String[] args) throws Exception { //A plant with no threads. new Plant(0); //Get a reference to the main thread. final Thread mainThread = Thread.currentThread(); //Create a thread-bound processing.
import org.agilewiki.jactor2.core.requests.AsyncResponseProcessor; import org.agilewiki.jactor2.core.requests.impl.AsyncRequestImpl; public class AllMain { public static void main(final String[] _args) throws Exception { new Plant(); try { new All(new A1("1"), new A1("2"), new A1("3")).call(); } finally { Plant.close(); }
import org.agilewiki.jactor2.core.requests.AsyncResponseProcessor; import org.agilewiki.jactor2.core.requests.impl.AsyncRequestImpl; public class Compound { public static void main(final String[] _args) throws Exception { new Plant(); try { final AA a = new AA(); a.startAOp().call(); } finally { Plant.close();
import java.io.IOException; public class ExceptionSample { public static void main(final String[] _args) throws Exception { new Plant(); try { A a = new A(); a.startAOp().call(); } finally { Plant.close();
5556575859606162636465
} } public class Decoupled { public static void main(final String[] _args) throws Exception { new Plant(); try { final AAA a = new AAA(); final BBB b = new BImpl(); a.startAOp(b).call(); } finally {