org.fusesource.hawtdispatch.Dispatch.createSource()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(120)

本文整理了Java中org.fusesource.hawtdispatch.Dispatch.createSource()方法的一些代码示例,展示了Dispatch.createSource()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Dispatch.createSource()方法的具体详情如下:
包路径:org.fusesource.hawtdispatch.Dispatch
类名称:Dispatch
方法名:createSource

Dispatch.createSource介绍

[英]Creates a new DispatchSource to monitor SelectableChannel objects and automatically submit a handler runnable to a dispatch queue in response to events.

You are allowed to create multiple dispatch sources to the same SelectableChannelobject.
[中]创建新的DispatchSource以监视SelectableChannel对象,并自动向调度队列提交可运行的处理程序以响应事件。
允许您为同一SelectableChannelobject创建多个分派源。

代码示例

代码示例来源:origin: org.apache.activemq/apollo-transport

public void run() {
  dispatchSource = Dispatch.createSource(EventAggregators.linkedList(), dispatchQueue);
  dispatchSource.setEventHandler(new Runnable() {
    public void run() {

代码示例来源:origin: jboss-fuse/fabric8

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);
}

代码示例来源:origin: org.apache.aries.rsa.provider/org.apache.aries.rsa.provider.fastbin

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);
}

代码示例来源:origin: org.apache.aries.rsa.provider/org.apache.aries.rsa.provider.fastbin

acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue);
acceptSource.setEventHandler(new Runnable() {
  public void run() {

代码示例来源:origin: org.fusesource.hawtdispatch/hawtdispatch-transport

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);

代码示例来源:origin: fusesource/hawtdispatch

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();
}

代码示例来源:origin: org.fusesource.hawtdispatch/hawtdispatch-transport

acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue);
acceptSource.setEventHandler(new Task() {
  public void run() {

代码示例来源:origin: org.apache.activemq/apollo-transport

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);
  }
}

代码示例来源:origin: org.apache.qpid/proton-hawtdispatch

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();
}

代码示例来源:origin: jboss-fuse/fabric8

acceptSource = Dispatch.createSource(channel, SelectionKey.OP_ACCEPT, dispatchQueue);
acceptSource.setEventHandler(new Runnable() {
  public void run() {

代码示例来源:origin: org.fusesource.hawtdispatch/hawtdispatch-transport

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);

代码示例来源:origin: org.fusesource.hawtdispatch/hawtdispatch-transport

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);
  }
}

代码示例来源:origin: org.fusesource.hawtdispatch/hawtdispatch-transport

public void run() {
  dispatchSource = Dispatch.createSource(EventAggregators.linkedList(), dispatchQueue);
  dispatchSource.setEventHandler(new Task() {
    public void run() {

代码示例来源:origin: org.apache.aries.rsa.provider/org.apache.aries.rsa.provider.fastbin

trace("connecting...");
readSource = Dispatch.createSource(channel, SelectionKey.OP_CONNECT, dispatchQueue);
readSource.setEventHandler(new Runnable() {
  public void run() {

代码示例来源:origin: jboss-fuse/fabric8

trace("connecting...");
readSource = Dispatch.createSource(channel, SelectionKey.OP_CONNECT, dispatchQueue);
readSource.setEventHandler(new Runnable() {
  public void run() {

相关文章