Package org.zeromq.ZMQ

Examples of org.zeromq.ZMQ.PollItem


        // After 10 msecs, send a ping message to output
        loop.addTimer(10, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);
        loop.start();

        loop.removePoller(pollInput);
View Full Code Here


        // After 10 msecs, fire a timer that registers
        // another timer that sends the ping message
        loop.addTimer(10, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);

        loop.start();
View Full Code Here

        // Fire a timer that sends the ping message
        loop.addTimer(0, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);

        loop.start();
View Full Code Here

        // Fire event that sends a ping message to output
        loop.addTimer(0, 1, timerEvent, input);

        // When we get the ping message, end the reactor
        PollItem pollInput = new PollItem(output, Poller.POLLIN);
        rc = loop.addPoller(pollInput, socketEvent, output);
        Assert.assertEquals(0, rc);
        loop.start();

        loop.removePoller(pollInput);
View Full Code Here

    // If you register the pollitem more than once, each instance will invoke its
    // corresponding handler.

    public int addPoller(PollItem item_, IZLoopHandler handler, Object arg) {

        PollItem item = item_;
        if (item.getRawSocket() == null && item.getSocket() == null)
            return -1;

        SPoller poller = new SPoller(item_, handler, arg);
        pollers.add(poller);

        dirty = true;
        if (verbose)
            System.out.printf("I: zloop: register %s poller (%s, %s)\n", item.getSocket() != null ? item.getSocket()
                    .getType() : "RAW", item.getSocket(), item.getRawSocket());
        return 0;
    }
View Full Code Here

    // Cancel a pollitem from the reactor, specified by socket or FD. If both
    // are specified, uses only socket. If multiple poll items exist for same
    // socket/FD, cancels ALL of them.

    public void removePoller(PollItem item_) {
        PollItem item = item_;

        Iterator<SPoller> it = pollers.iterator();
        while (it.hasNext()) {
            SPoller p = it.next();
            if (item.equals(p.item)) {
                it.remove();
                dirty = true;
            }
        }
        if (verbose)
            System.out.printf("I: zloop: cancel %s poller (%s, %s)", item.getSocket() != null ? item.getSocket()
                    .getType() : "RAW", item.getSocket(), item.getRawSocket());

    }
View Full Code Here

                return;
            }

            pipe.send("OK");

            PollItem[] pollItems = {new PollItem(pipe, Poller.POLLIN), new PollItem(handler, Poller.POLLIN)};
            while (!terminated && !Thread.currentThread().isInterrupted()) {
                int rc = ZMQ.poll(pollItems, -1);
                if (rc == -1) {
                    break; //interrupt
View Full Code Here

    }

    public void run()
    {
        //  Register our handlers with reactor
        PollItem poller = new PollItem(snapshot, ZMQ.Poller.POLLIN);
        loop.addPoller(poller, new Snapshots(), this);
        poller = new PollItem(collector, ZMQ.Poller.POLLIN);
        loop.addPoller(poller, new Collector(), this);
        loop.addTimer(1000, 0, new FlushTTL(), this);

        loop.start();
        loop.destroy();
View Full Code Here

        public void run(Object[] args, ZContext ctx, Socket pipe)
        {
            Agent agent = new Agent(ctx, pipe);

            PollItem[] items = {
                    new PollItem(agent.pipe, ZMQ.Poller.POLLIN),
                    new PollItem(agent.router, ZMQ.Poller.POLLIN)
            };
            while (!Thread.currentThread().isInterrupted()) {
                //  Calculate tickless timer, up to 1 hour
                long tickless = System.currentTimeMillis() + 1000 * 3600;
                if (agent.request != null
View Full Code Here

            client.send(request);

            boolean expectReply = true;
            while (expectReply) {
                //  Poll socket for a reply, with timeout
                PollItem items [] = { new PollItem(client, ZMQ.Poller.POLLIN) };
                int rc = ZMQ.poll(items, 1, REQUEST_TIMEOUT);
                if (rc == -1)
                    break;          //  Interrupted

                //  .split main body of client
View Full Code Here

TOP

Related Classes of org.zeromq.ZMQ.PollItem

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.