Package kilim

Examples of kilim.Scheduler


     * The task contains an endpoint object, the bridge between the NIO system
     * and Kilim's scheduling.
     */
    public static class Server extends SessionTask {
        public static void run() throws IOException {
            Scheduler sessionScheduler = Scheduler.getDefaultScheduler(); // The scheduler/thread pool on which all tasks will be run
            NioSelectorScheduler nio = new NioSelectorScheduler(); // Starts a single thread that manages the select loop
            nio.listen(port, Server.class, sessionScheduler); //
        }
View Full Code Here


public class TestInterface extends TestCase {
    public void testIntCall() throws Exception {
        Task task = new kilim.test.ex.ExInterfaceImpl();
        Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
        Scheduler s = new Scheduler(1);
        task.informOnExit(exitmb);
        task.setScheduler(s);
        task.start();
       
        ExitMsg m = exitmb.getb();
        if (m == null) {
            fail("Timed Out");
        } else {
            Object res = m.result;
            if (res instanceof Throwable) {
                ((Throwable)res).printStackTrace();
                fail(m.toString());
            }
        }
        s.shutdown();
    }
View Full Code Here

        }
    }
    public void testGenericInterface() throws Exception {
        ExInterfaceGenericTask task = new ExInterfaceGenericTask(new ExInterfaceGenericImpl());
        Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
        Scheduler s = new Scheduler(1);
        task.informOnExit(exitmb);
        task.setScheduler(s);
        task.start();
       
        ExitMsg m = exitmb.getb();
        if (m == null) {
            fail("Timed Out");
        } else {
            Object res = m.result;
            if (res instanceof Throwable) {
                ((Throwable)res).printStackTrace();
                fail(m.toString());
            }
            if (task.getResponse != "foo") {
              fail("Expected 'foo', got '" + res + "'");
            }
        }
        s.shutdown();
    }
View Full Code Here

        runTask(task);
    }

    public static void runTask(Task task) throws Exception {
        Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
        Scheduler s = new Scheduler(1);
        task.informOnExit(exitmb);
        task.setScheduler(s);
        task.start();
       
        ExitMsg m = exitmb.getb();
        if (m == null) {
            fail("Timed Out");
        } else {
            Object res = m.result;
            if (res instanceof Throwable) {
                ((Throwable)res).printStackTrace();
                fail(m.toString());
            }
        }
        s.shutdown();
    }
View Full Code Here

        runTask(task);
    }

    public static void runTask(Task task) throws Exception {
        Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
        Scheduler s = new Scheduler(1);
        task.informOnExit(exitmb);
        task.setScheduler(s);
        task.start();
       
        ExitMsg m = exitmb.getb();
        if (m == null) {
            fail("Timed Out");
        } else {
            Object res = m.result;
            if (res instanceof Throwable) {
                ((Throwable)res).printStackTrace();
                fail(m.toString());
            }
        }
        s.shutdown();
    }
View Full Code Here

public class TestInterface extends TestCase {
    public void testIntCall() throws Exception {
        Task task = new kilim.test.ex.ExInterfaceImpl();
        Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
        Scheduler s = new Scheduler(1);
        task.informOnExit(exitmb);
        task.setScheduler(s);
        task.start();
       
        ExitMsg m = exitmb.getb();
        if (m == null) {
            fail("Timed Out");
        } else {
            Object res = m.result;
            if (res instanceof Throwable) {
                ((Throwable)res).printStackTrace();
                fail(m.toString());
            }
        }
        s.shutdown();
    }
View Full Code Here

        runTask(task);
    }

    public static void runTask(Task task) throws Exception {
        Mailbox<ExitMsg> exitmb = new Mailbox<ExitMsg>();
        Scheduler s = new Scheduler(1);
        task.informOnExit(exitmb);
        task.setScheduler(s);
        task.start();
       
        ExitMsg m = exitmb.getb();
        if (m == null) {
            fail("Timed Out");
        } else {
            Object res = m.result;
            if (res instanceof Throwable) {
                ((Throwable)res).printStackTrace();
                fail(m.toString());
            }
        }
        s.shutdown();
    }
View Full Code Here

import kilim.Scheduler;
import kilim.Task;

public class TestLock extends TestCase{
    public void testLocks() {
        Scheduler scheduler = new Scheduler(4);
        Mailbox<ExitMsg> mb = new Mailbox<ExitMsg>();
        for (int i = 0; i < 100; i++) {
            Task t = new LockTask();
            t.informOnExit(mb);
            t.setScheduler(scheduler);
            t.start();
        }
        boolean ok = true;
        for (int i = 0; i < 100; i++) {
            ExitMsg em = mb.getb(5000);
            assertNotNull("Timed out. #tasks finished = " + i + "/100", em);
            if (em.result instanceof Exception) {
                ok = false; break;
            }
        }
        scheduler.shutdown();
        assertTrue(ok);
    }
View Full Code Here

TOP

Related Classes of kilim.Scheduler

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.