Package org.agilewiki.jactor

Examples of org.agilewiki.jactor.MailboxFactory


/**
* Test code.
*/
public class Test5 extends TestCase {
    public void test() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);
        Mailbox mailbox = mailboxFactory.createMailbox();
        Actor5a actor5a = new Actor5a();
        actor5a.initialize(mailbox);
        JAFuture future = new JAFuture();
        boolean response = Parallel.req.send(future, actor5a);
        assertEquals(true, response);
        mailboxFactory.close();
    }
View Full Code Here


/**
* Test code.
*/
public class SetFTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            SetF1 actor = new SetF1();
            actor.initialize(mailboxFactory.createMailbox());
            JAFuture future = new JAFuture();
            System.out.println(SimpleRequest.req.send(future, actor));
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

/**
* Test code.
*/
public class CallTest extends TestCase {
    public void test() {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Call actor = new Call();
            actor.initialize(mailboxFactory.createMailbox());
            JAFuture future = new JAFuture();
            System.out.println(SimpleRequest.req.send(future, actor));
        } catch (Throwable e) {
            e.printStackTrace();
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

/**
* Test code.
*/
public class Test2a extends TestCase {
    public void test() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);
        Mailbox mailbox = mailboxFactory.createMailbox();
        Actor1 actor1 = new Actor1();
        actor1.initialize(mailbox);
        Actor2 actor2 = new Actor2();
        actor2.initialize(mailbox, actor1);
        JAFuture future = new JAFuture();
        String result = Hi1.req.send(future, actor2);
        assertEquals("Hello world!", result);
        mailboxFactory.close();
    }
View Full Code Here

/**
* Test code.
*/
public class Test1 extends TestCase {
    public void test() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);
        Mailbox mailbox = mailboxFactory.createMailbox();
        Actor1 actor1 = new Actor1();
        actor1.initialize(mailbox);
        JAFuture future = new JAFuture();
        String result = Hi1.req.send(future, actor1);
        assertEquals("Hello world!", result);
        mailboxFactory.close();
    }
View Full Code Here

        //int r = 10000;
        //int s = 10000;
        //mps = 19857029


        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        Mailbox mailbox = mailboxFactory.createMailbox();
        Driver driver = new Driver();
        driver.initialize(mailbox);
        driver.r = r;
        driver.s = s;
        JAFuture future = new JAFuture();
        JAPublisher pub = new JAPublisher();
        pub.initialize(mailbox);
        driver.pub = pub;
        Go.req.send(future, driver);
        pub = new JAPublisher();
        pub.initialize(mailbox);
        driver.pub = pub;
        Go.req.send(future, driver);
        pub = new JAPublisher();
        pub.initialize(mailbox);
        driver.pub = pub;
        long t0 = System.currentTimeMillis();
        Go.req.send(future, driver);
        long t1 = System.currentTimeMillis();
        long t = t1 - t0;
        long tm = r * s;
        if (t > 0L) {
            System.out.println("messages: " + tm);
            System.out.println("milliseconds: " + t);
            System.out.println("messages per second: " + (1000L * tm / t));
        }
        mailboxFactory.close();
    }
View Full Code Here

        //long runs = 1000000000;
        //[java-shared] Number of runs: 1000000000
        //[java-shared] Count: 100000000000
        //[java-shared] Test time in seconds: 10.457
        //[java-shared] Messages per second: 9.562972171750979E7
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);
        try {
            Mailbox sharedMailbox = mailboxFactory.createMailbox();
            CounterActor counterActor = new CounterActor();
            counterActor.initialize(sharedMailbox);
            Driver driver = new Driver();
            driver.initialize(sharedMailbox, counterActor, runs);
            JAFuture future = new JAFuture();
            long start = System.currentTimeMillis();
            Long count = (Long) SimpleRequest.req.send(future, driver);
            long finish = System.currentTimeMillis();
            double elapsedTime = (finish - start) / 1000.;
            System.out.println("[java-shared] Number of runs: " + runs);
            System.out.println("[java-shared] Count: " + count);
            System.out.println("[java-shared] Test time in seconds: " + elapsedTime);
            System.out.println("[java-shared] Messages per second: " + runs / elapsedTime);
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

        //long runs = 1000000000;
        //[java-unshared] Number of runs: 1000000000
        //[java-unshared] Count: 100000000000
        //[java-unshared] Test time in seconds: 52.955
        //[java-unshared] Messages per second: 1.8883958077613067E7
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);
        try {
            CounterActor counterActor = new CounterActor();
            counterActor.initialize(mailboxFactory.createMailbox());
            Driver driver = new Driver();
            driver.initialize(mailboxFactory.createMailbox(), counterActor, runs);
            JAFuture future = new JAFuture();
            long start = System.currentTimeMillis();
            Long count = (Long) SimpleRequest.req.send(future, driver);
            long finish = System.currentTimeMillis();
            double elapsedTime = (finish - start) / 1000.;
            System.out.println("[java-unshared] Number of runs: " + runs);
            System.out.println("[java-unshared] Count: " + count);
            System.out.println("[java-unshared] Test time in seconds: " + elapsedTime);
            System.out.println("[java-unshared] Messages per second: " + runs / elapsedTime);
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

//        [java-async] Number of runs: 10000000
//        [java-async] Count: 1000000000
//        [java-async] Test time in seconds: 7.598
//        [java-async] Messages per second: 1316135.8252171625

        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(10);
        try {
            CounterActor counterActor = new CounterActor();
            counterActor.initialize(mailboxFactory.createAsyncMailbox());
            Driver driver = new Driver();
            driver.initialize(mailboxFactory.createMailbox(), counterActor, runs);
            JAFuture future = new JAFuture();
            long start = System.currentTimeMillis();
            Long count = (Long) SimpleRequest.req.send(future, driver);
            long finish = System.currentTimeMillis();
            double elapsedTime = (finish - start) / 1000.;
            System.out.println("[java-async] Number of runs: " + runs);
            System.out.println("[java-async] Count: " + count);
            System.out.println("[java-async] Test time in seconds: " + elapsedTime);
            System.out.println("[java-async] Messages per second: " + runs / elapsedTime);
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

/**
* Test code.
*/
public class FactorialTest extends TestCase {
    public void testFactorial() throws Exception {
        MailboxFactory mailboxFactory = JAMailboxFactory.newMailboxFactory(1);
        try {
            Factorial factorial = new Factorial();
            factorial.initialize(mailboxFactory.createMailbox());
            JAFuture future = new JAFuture();
            SimpleRequest.req.send(future, factorial);
        } finally {
            mailboxFactory.close();
        }
    }
View Full Code Here

TOP

Related Classes of org.agilewiki.jactor.MailboxFactory

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.