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);
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()); } } }
@Override public Pipe pipe() throws IOException { return Pipe.open(); }
@Override public Pipe pipe() throws IOException { return Pipe.open(); }
public ReactorDispatcher(final Reactor reactor) throws IOException { this.reactor = reactor; this.ioSignal = Pipe.open(); this.workQueue = new ConcurrentLinkedQueue<>(); this.workScheduler = new ScheduleHandler(); initializeSelectable(); }
public ReactorDispatcher(final Reactor reactor) throws IOException { this.reactor = reactor; this.ioSignal = Pipe.open(); this.workQueue = new ConcurrentLinkedQueue<BaseHandler>(); this.workScheduler = new ScheduleHandler(); initializeSelectable(); }
Pipe pipe = Pipe.open(); SinkChannel sink = pipe.sink(); SourceChannel source = pipe.source();
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); }
@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 }); }
@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); } }
@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); } }
@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); } }