Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
Copyright (c) 1991-2011 iMatix Corporation
Copyright other contributors as noted in the AUTHORS file.
This file is part of 0MQ.
0MQ is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
0MQ is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License
along with this program. If not, see .
*/
package org.zeromq;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.zeromq.ZMQ.PollItem;
import org.zeromq.ZMQ.Poller;
/**
* The ZLoop class provides an event-driven reactor pattern. The reactor handles zmq.PollItem items (pollers or writers,
* sockets or fds), and once-off or repeated timers. Its resolution is 1 msec. It uses a tickless timer to reduce CPU
* interrupts in inactive processes.
*/
public class ZLoop {
public static interface IZLoopHandler {
public int handle(ZLoop loop, PollItem item, Object arg);
}
private class SPoller {
PollItem item;
IZLoopHandler handler;
Object arg;
int errors; // If too many errors, kill poller
protected SPoller(PollItem item, IZLoopHandler handler, Object arg) {
this.item = item;
this.handler = handler;
this.arg = arg;
errors = 0;
}
}
;
private class STimer {
int delay;
int times;
IZLoopHandler handler;
Object arg;
long when; // Clock time when alarm goes off
public STimer(int delay, int times, IZLoopHandler handler, Object arg) {
this.delay = delay;
this.times = times;
this.handler = handler;
this.arg = arg;
this.when = -1;
}
}
private final List pollers; // List of poll items
private final List timers; // List of timers
private int pollSize; // Size of poll set
private Poller pollset; // zmq_poll set
private SPoller[] pollact; // Pollers for this poll set
private boolean dirty; // True if pollset needs rebuilding
private boolean verbose; // True if verbose tracing wanted
private final List