public void run() { dispatchSource = Dispatch.createSource(EventAggregators.linkedList(), dispatchQueue); dispatchSource.setEventHandler(new Runnable() { public void run() { try {
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(); }
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(); }
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() { try {
protected void onConnected() throws IOException { yieldSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); yieldSource.setEventHandler(new Task() { public void run() { drainInbound(); yieldSource.resume(); drainOutboundSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); drainOutboundSource.setEventHandler(new Task() { public void run() { flush();
protected void onConnected() throws IOException { yieldSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); yieldSource.setEventHandler(new Task() { public void run() { drainInbound(); yieldSource.resume(); drainOutboundSource = Dispatch.createSource(EventAggregators.INTEGER_ADD, dispatchQueue); drainOutboundSource.setEventHandler(new Task() { public void run() { flush();