java.nio.channels.Pipe.open()方法的使用及代码示例

x33g5p2x  于2022-01-26 转载在 其他  
字(6.7k)|赞(0)|评价(0)|浏览(129)

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

Pipe.open介绍

[英]Returns a new pipe from the default java.nio.channels.spi.SelectorProvider.
[中]从默认java返回一个新管道。尼奥。频道。spi。选择器提供程序。

代码示例

代码示例来源:origin: wildfly/wildfly

public ChannelPipe<StreamConnection, StreamConnection> createFullDuplexPipeConnection(XnioIoFactory peer) throws IOException {
  getWorker().checkShutdown();
  boolean ok = false;
  final Pipe topPipe = Pipe.open();
  try {
    topPipe.source().configureBlocking(false);
    topPipe.sink().configureBlocking(false);
    final Pipe bottomPipe = Pipe.open();
    try {
      bottomPipe.source().configureBlocking(false);

代码示例来源:origin: wildfly/wildfly

public ChannelPipe<StreamSourceChannel, StreamSinkChannel> createHalfDuplexPipe(final XnioIoFactory peer) throws IOException {
  getWorker().checkShutdown();
  final Pipe pipe = Pipe.open();
  boolean ok = false;
  try {
    pipe.source().configureBlocking(false);
    pipe.sink().configureBlocking(false);
    final WorkerThread peerThread = getPeerThread(peer);
    final SelectionKey readKey = registerChannel(pipe.source());
    final SelectionKey writeKey = peerThread.registerChannel(pipe.sink());
    final NioPipeStreamConnection leftConnection = new NioPipeStreamConnection(this, readKey, null);
    final NioPipeStreamConnection rightConnection = new NioPipeStreamConnection(this, null, writeKey);
    leftConnection.writeClosed();
    rightConnection.readClosed();
    final ChannelPipe<StreamSourceChannel,StreamSinkChannel> result = new ChannelPipe<StreamSourceChannel, StreamSinkChannel>(leftConnection.getSourceChannel(), rightConnection.getSinkChannel());
    ok = true;
    return result;
  } finally {
    if (! ok) {
      safeClose(pipe.sink());
      safeClose(pipe.source());
    }
  }
}

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

@Override
public Pipe pipe() throws IOException {
  return Pipe.open();
}

代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot

@Override
public Pipe pipe() throws IOException {
  return Pipe.open();
}

代码示例来源:origin: perlundq/yajsync

private static Pipe[] pipePair()
{
  try {
    return new Pipe[] { Pipe.open(), Pipe.open() };
  } catch (IOException e) {
    throw new RuntimeException(e);
  }
}

代码示例来源:origin: org.terracotta/terracotta-l1-ee

public PipeSocket(Socket socket) throws IOException {
 this.socket = socket;
 this.inputPipe = Pipe.open();
 this.outputPipe = Pipe.open();
 this.outputPipe.source().configureBlocking(false);
}

代码示例来源:origin: org.terracotta/terracotta-ee

public PipeSocket(Socket socket) throws IOException {
 this.socket = socket;
 this.inputPipe = Pipe.open();
 this.outputPipe = Pipe.open();
 this.outputPipe.source().configureBlocking(false);
}

代码示例来源:origin: org.terracotta/terracotta-l1

public PipeSocket(Socket socket) throws IOException {
 this.socket = socket;
 this.inputPipe = Pipe.open();
 this.outputPipe = Pipe.open();
 this.outputPipe.source().configureBlocking(false);
}

代码示例来源:origin: Azure/azure-event-hubs-java

public ReactorDispatcher(final Reactor reactor) throws IOException {
  this.reactor = reactor;
  this.ioSignal = Pipe.open();
  this.workQueue = new ConcurrentLinkedQueue<>();
  this.workScheduler = new ScheduleHandler();
  initializeSelectable();
}

代码示例来源:origin: Azure/azure-service-bus-java

public ReactorDispatcher(final Reactor reactor) throws IOException
{
  this.reactor = reactor;
  this.ioSignal = Pipe.open();
  this.workQueue = new ConcurrentLinkedQueue<BaseHandler>();
  this.workScheduler = new ScheduleHandler();
  
  initializeSelectable();
}

代码示例来源:origin: jenkinsci/remoting

@Before
public void setUpPipe() throws Exception {
  clientToServer = Pipe.open();
  serverToClient = Pipe.open();
}

代码示例来源:origin: jenkinsci/remoting

@Before
public void setUpPipe() throws Exception {
  clientToServer = Pipe.open();
  serverToClient = Pipe.open();
}

代码示例来源:origin: jenkinsci/remoting

@Before
public void setUpPipe() throws Exception {
  clientToServer = Pipe.open();
  serverToClient = Pipe.open();
}

代码示例来源:origin: stackoverflow.com

Pipe pipe = Pipe.open();
SinkChannel sink = pipe.sink();
SourceChannel source = pipe.source();

代码示例来源:origin: jenkinsci/remoting

@Before
public void setUp() throws Exception {
  clientToServer = Pipe.open();
  serverToClient = Pipe.open();
  executorService = Executors.newFixedThreadPool(8);
  hub = IOHub.create(executorService);
}

代码示例来源:origin: indeedeng/imhotep

public NBCircularIOStream() throws IOException {
  final Pipe pipe = Pipe.open();
  sink = new BufferedWritableSelectableChannel(new PipeSinkWritableSelectableChannel(pipe.sink()));
  final Pipe.SourceChannel source = pipe.source();
  sink.configureBlocking(false);
  source.configureBlocking(true);
  in = Channels.newInputStream(source);
}

代码示例来源:origin: org.netbeans.api/org-jruby

@JRubyMethod(name = "pipe", meta = true)
public static IRubyObject pipe(ThreadContext context, IRubyObject recv) throws Exception {
  // TODO: This isn't an exact port of MRI's pipe behavior, so revisit
  Ruby runtime = context.getRuntime();
  Pipe pipe = Pipe.open();
    RubyIO source = new RubyIO(runtime, pipe.source());
  RubyIO sink = new RubyIO(runtime, pipe.sink());
    sink.openFile.getMainStream().setSync(true);
  return runtime.newArrayNoCopy(new IRubyObject[] { source, sink });
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@JRubyMethod(name = "pipe", meta = true, compat = RUBY1_8)
public static IRubyObject pipe(ThreadContext context, IRubyObject recv) {
  // TODO: This isn't an exact port of MRI's pipe behavior, so revisit
  Ruby runtime = context.runtime;
  try {
    Pipe pipe = Pipe.open();
    RubyIO source = new RubyIO(runtime, pipe.source());
    RubyIO sink = new RubyIO(runtime, pipe.sink());
    sink.openFile.getMainStreamSafe().setSync(true);
    return runtime.newArrayNoCopy(new IRubyObject[]{source, sink});
  } catch (BadDescriptorException e) {
    throw runtime.newErrnoEBADFError();
  } catch (IOException ioe) {
    throw runtime.newIOErrorFromException(ioe);
  }
}

代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby

@JRubyMethod(name = "pipe", meta = true, compat = RUBY1_8)
public static IRubyObject pipe(ThreadContext context, IRubyObject recv) {
  // TODO: This isn't an exact port of MRI's pipe behavior, so revisit
  Ruby runtime = context.runtime;
  try {
    Pipe pipe = Pipe.open();
    RubyIO source = new RubyIO(runtime, pipe.source());
    RubyIO sink = new RubyIO(runtime, pipe.sink());
    sink.openFile.getMainStreamSafe().setSync(true);
    return runtime.newArrayNoCopy(new IRubyObject[]{source, sink});
  } catch (BadDescriptorException e) {
    throw runtime.newErrnoEBADFError();
  } catch (IOException ioe) {
    throw runtime.newIOErrorFromException(ioe);
  }
}

代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby

@JRubyMethod(name = "pipe", meta = true, compat = RUBY1_9)
public static IRubyObject pipe19(ThreadContext context, IRubyObject recv, IRubyObject modes, IRubyObject options) {
  Ruby runtime = context.runtime;
  try {
    Pipe pipe = Pipe.open();
    RubyIO source = new RubyIO(runtime, pipe.source());
    source.setEncoding(context, modes, context.nil, options);
    RubyIO sink = new RubyIO(runtime, pipe.sink());
    sink.openFile.getMainStreamSafe().setSync(true);
    return runtime.newArrayNoCopy(new IRubyObject[]{source, sink});
  } catch (BadDescriptorException e) {
    throw runtime.newErrnoEBADFError();
  } catch (IOException ioe) {
    throw runtime.newIOErrorFromException(ioe);
  }
}

相关文章