Examples of PollItem


Examples of org.zeromq.ZMQ.PollItem

            //  Set random identity to make tracing easier
            String identity = String.format("%04X-%04X", rand.nextInt(), rand.nextInt());
            client.setIdentity(identity.getBytes());
            client.connect("tcp://localhost:5570");

            PollItem[] items = new PollItem[] { new PollItem(client, Poller.POLLIN) };

            int requestNbr = 0;
            while (!Thread.currentThread().isInterrupted()) {
                //  Tick once per second, pulling in arriving messages
                for (int centitick = 0; centitick < 100; centitick++) {
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        //  Set timer for next outgoing state message
        long sendStateAt = System.currentTimeMillis() + HEARTBEAT;
        while (!Thread.currentThread().isInterrupted()) {
            PollItem[] items = {
                    new PollItem(frontend, ZMQ.Poller.POLLIN),
                    new PollItem(statesub, ZMQ.Poller.POLLIN),
            };
            int timeLeft = (int) ((sendStateAt - System.currentTimeMillis()));
            if (timeLeft < 0)
                timeLeft = 0;
            int rc = ZMQ.poll(items, 2, timeLeft);
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        //  Queue of available workers
        ArrayList<ZFrame> workers = new ArrayList<ZFrame> ();
       
        //  The body of this example is exactly the same as lruqueue2.
        while (true) {
            PollItem items [] = {
                new PollItem( backend,  Poller.POLLIN ),
                new PollItem( frontend, Poller.POLLIN )
            };
            int rc = ZMQ.poll (items, workers.size() > 0 ? 2 : 1, -1);

            //  Poll frontend only if we have available workers
            if (rc == -1)
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        //  Register state change handlers
        bStar.newActive(new NewActive(), this);
        bStar.newPassive(new NewPassive(), this);

        //  Register our other handlers with the bstar reactor
        PollItem poller = new PollItem(collector, ZMQ.Poller.POLLIN);

        bStar.zloop().addPoller(poller, new Collector(), this);
        bStar.zloop().addTimer(1000, 0, new FlushTTL(), this);
        bStar.zloop().addTimer(1000, 0, new SendHugz(), this);
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

            srv.active = true;
            srv.passive = false;

            //  Stop subscribing to updates
            PollItem poller = new PollItem(srv.subscriber, ZMQ.Poller.POLLIN);
            srv.bStar.zloop().removePoller(poller);

            //  Apply pending list to own hash table
            for (kvmsg msg: srv.pending) {
                msg.setSequence(++srv.sequence);
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

            }
            srv.active = false;
            srv.passive = true;

            //  Start subscribing to updates
            PollItem poller = new PollItem(srv.subscriber, ZMQ.Poller.POLLIN);
            srv.bStar.zloop().addPoller(poller, new Subscriber(), srv);
            return 0;
        }
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        ZThread.start(new TitanicClose());

        //  Main dispatcher loop
        while (true) {
            //  We'll dispatch once per second, if there's no activity
            PollItem items [] = { new PollItem(requestPipe, ZMQ.Poller.POLLIN) };
            int rc = ZMQ.poll(items, 1, 1000);
            if (rc == -1)
                break;              //  Interrupted
            if (items [0].isReadable()) {
                //  Ensure message directory exists
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

        //  Queue of available workers
        arg.workers = new LinkedList<ZFrame> ();

        //  Prepare reactor and fire it up
        ZLoop reactor = new ZLoop ();
        PollItem item = new PollItem (arg.backend, ZMQ.Poller.POLLIN);
        reactor.addPoller (item, backendHandler, arg);
        reactor.start ();

        context.destroy ();
    }
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

                msg.wrap(arg.workers.poll());
                msg.send(arg.backend);

                //  Cancel reader on frontend if we went from 1 to 0 workers
                if (arg.workers.size() == 0) {
                    loop.removePoller (new PollItem (arg.frontend, 0));
                }
            }
            return 0;
        }
View Full Code Here

Examples of org.zeromq.ZMQ.PollItem

                //  Queue worker address for load-balancing
                arg.workers.add(address);

                //  Enable reader on frontend if we went from 0 to 1 workers
                if (arg.workers.size() == 1) {
                    PollItem newItem = new PollItem (arg.frontend, ZMQ.Poller.POLLIN);
                    loop.addPoller (newItem, frontendHandler, arg);
                }

                //  Forward message to client if it's not a READY
                ZFrame frame = msg.getFirst();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.