public void run() { dispatchSource = Dispatch.createSource(EventAggregators.linkedList(), dispatchQueue); dispatchSource.setEventHandler(new Runnable() { public void run() {
protected void onConnected() throws IOException { readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue); readSource.setCancelHandler(CANCEL_HANDLER); writeSource.setCancelHandler(CANCEL_HANDLER); readSource.setEventHandler(new Runnable() { public void run() { drainInbound(); } }); writeSource.setEventHandler(new Runnable() { public void run() { drainOutbound(); } }); if( max_read_rate!=0 || max_write_rate!=0 ) { rateLimitingChannel = new RateLimitingChannel(); schedualRateAllowanceReset(); } remoteAddress = channel.socket().getRemoteSocketAddress().toString(); listener.onTransportConnected(this); }
protected void onConnected() throws IOException { readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue); readSource.setCancelHandler(CANCEL_HANDLER); writeSource.setCancelHandler(CANCEL_HANDLER); readSource.setEventHandler(new Runnable() { public void run() { drainInbound(); } }); writeSource.setEventHandler(new Runnable() { public void run() { drainOutbound(); } }); if( max_read_rate!=0 || max_write_rate!=0 ) { rateLimitingChannel = new RateLimitingChannel(); schedualRateAllowanceReset(); } remoteAddress = channel.socket().getRemoteSocketAddress().toString(); listener.onTransportConnected(this); }
acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue); acceptSource.setEventHandler(new Runnable() { public void run() {
protected void onConnected() throws IOException { yieldSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); yieldSource.setEventHandler(new Task() { public void run() { drainOutboundSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); drainOutboundSource.setEventHandler(new Task() { public void run() { drainOutboundSource.resume(); readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue);
public AggregatingExecutor(DispatchQueue queue) { this.queue = queue; this.source = createSource(EventAggregators.<Runnable>linkedList(), queue); this.source.setEventHandler(new Task() { public void run() { for (Runnable runnable: source.getData() ) { try { runnable.run(); } catch (Exception e) { Thread thread = Thread.currentThread(); thread.getUncaughtExceptionHandler().uncaughtException(thread, e); } } } }); this.source.resume(); }
acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue); acceptSource.setEventHandler(new Task() { public void run() {
public void start(Runnable onCompleted) throws Exception { acceptSource = Dispatch.createSource(EventAggregators.<PipeTransport>linkedList(), dispatchQueue); acceptSource.setEventHandler(new Runnable() { public void run() { LinkedList<PipeTransport> transports = acceptSource.getData(); for (PipeTransport transport : transports) { listener.onAccept(transport); } } }); acceptSource.resume(); if( onCompleted!=null ) { dispatchQueue.execute(onCompleted); } }
private AmqpTransport(DispatchQueue queue) { this.queue = queue; this.connection = (ProtonJConnection) Connection.Factory.create(); defers = Dispatch.createSource(EventAggregators.<Defer>linkedList(), this.queue); defers.setEventHandler(new Task(){ public void run() { for( Defer defer: defers.getData() ) { assert defer.defered = true; defer.defered = false; defer.run(); } } }); defers.resume(); }
acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue); acceptSource.setEventHandler(new Runnable() { public void run() {
protected void onConnected() throws IOException { yieldSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); yieldSource.setEventHandler(new Task() { public void run() { drainOutboundSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); drainOutboundSource.setEventHandler(new Task() { public void run() { drainOutboundSource.resume(); readSource = Dispatch.createSource(channel, SelectionKey.OP_READ, dispatchQueue); writeSource = Dispatch.createSource(channel, SelectionKey.OP_WRITE, dispatchQueue);
public void start(Task onCompleted) throws Exception { acceptSource = Dispatch.createSource(EventAggregators.<PipeTransport>linkedList(), dispatchQueue); acceptSource.setEventHandler(new Task() { public void run() { LinkedList<PipeTransport> transports = acceptSource.getData(); for (PipeTransport transport : transports) { try { listener.onAccept(transport); } catch (Exception e) { listener.onAcceptError(e); } } } }); acceptSource.resume(); if( onCompleted!=null ) { dispatchQueue.execute(onCompleted); } }
public void run() { dispatchSource = Dispatch.createSource(EventAggregators.linkedList(), dispatchQueue); dispatchSource.setEventHandler(new Task() { public void run() {
trace("connecting..."); readSource = Dispatch.createSource(channel, SelectionKey.OP_CONNECT, dispatchQueue); readSource.setEventHandler(new Runnable() { public void run() {
trace("connecting..."); readSource = Dispatch.createSource(channel, SelectionKey.OP_CONNECT, dispatchQueue); readSource.setEventHandler(new Runnable() { public void run() {