ZLoop { public ZLoop() { pollers = new ArrayList<SPoller>(); timers = new ArrayList<STimer>(); zombies = new ArrayList<Object>(); newTimers = new ArrayList<STimer>(); } ZLoop(); void destroy(); int addPoller(PollItem item_, IZLoopHandler handler, Object arg); void removePoller(PollItem item_); int addTimer(int delay, int times, IZLoopHandler handler, Object arg); int removeTimer(Object arg); void verbose(boolean verbose); int start();  }
@Test public void testZLoop() { int rc = 0; ZLoop loop = new ZLoop(); assert (loop != null); ZLoop.IZLoopHandler timerEvent = new ZLoop.IZLoopHandler() { @Override public int handle(ZLoop loop, PollItem item, Object arg) { ((Socket) arg).send("PING", 0); return 0; } }; ZLoop.IZLoopHandler socketEvent = new ZLoop.IZLoopHandler() { @Override public int handle(ZLoop loop, PollItem item, Object arg) { received = ((Socket) arg).recvStr(0); return -1; } }; loop.addTimer(10, 1, timerEvent, input); PollItem pollInput = new PollItem(output, Poller.POLLIN); rc = loop.addPoller(pollInput, socketEvent, output); Assert.assertEquals(0, rc); loop.start(); loop.removePoller(pollInput); Assert.assertEquals("PING", received); }