Package java.nio.channels

Examples of java.nio.channels.Pipe$SourceChannel


    // NIO based pipe
    @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 });
   }
View Full Code Here


      dispatcher.enqueueMessage(SourcesMessage.createSetSourcesIdsMessage(sourcesMap.values()));
      dispatcher.enqueueMessage(SourcesMessage.createSetSourcesSchemasMessage(schemaMap));

      log.info("starting event dispatch");
      //comm channels between reader and writer
      Pipe pipe = Pipe.open();
      Pipe.SinkChannel writerStream = pipe.sink();
      Pipe.SourceChannel readerStream = pipe.source();
      writerStream.configureBlocking(true);
      /*
       *  Needed for DbusEventBuffer.readEvents() to exit their loops when no more data is available.
       *  With Pipe mimicking ChunkedBodyReadableByteChannel, we need to make Pipe non-blocking on the
       *  reader side to achieve the behavior that ChunkedBodyReadableByte channel provides.
View Full Code Here

      log.info("starting event dispatch");

      //stream the events from the source buffer without the EOW

      //comm channels between reader and writer
      Pipe pipe = Pipe.open();
      Pipe.SinkChannel writerStream = pipe.sink();
      Pipe.SourceChannel readerStream = pipe.source();
      writerStream.configureBlocking(true);
      readerStream.configureBlocking(false);

      //Event writer - Relay in the real world
      Checkpoint cp = Checkpoint.createFlexibleCheckpoint();
View Full Code Here

 
  @Test
  public void testSocketIOWithTimeout() throws Exception {
   
    // first open pipe:
    Pipe pipe = Pipe.open();
    Pipe.SourceChannel source = pipe.source();
    Pipe.SinkChannel sink = pipe.sink();
   
    try {
      final InputStream in = new SocketInputStream(source, TIMEOUT);
      OutputStream out = new SocketOutputStream(sink, TIMEOUT);
     
View Full Code Here

    private FileDescriptor[] writable;

    public SelectorImpl(SelectorProvider selectorProvider) {
        super(selectorProvider);
        try {
            Pipe mockSelector = selectorProvider.openPipe();
            sink = mockSelector.sink();
            source = mockSelector.source();
            sourcefd = ((FileDescriptorHandler)source).getFD();
            source.configureBlocking(false);
        } catch (IOException e) {
            // do nothing
        }
View Full Code Here

    private final InputStream in;
    private final Pipe pipe;

    public static NioInputStreamChannel create(NodeProcess process, InputStream in) throws IOException {
        Pipe pipe = Pipe.open();
        return new NioInputStreamChannel(process, in, pipe);
    }
View Full Code Here

    private final OutputStream out;
    private final Pipe inPipe;
    private final Pipe outPipe;

    public static NioDuplexStreamChannel create(NodeProcess process, InputStream in, OutputStream out) throws IOException {
        Pipe inPipe = Pipe.open();
        Pipe outPipe = Pipe.open();
        return new NioDuplexStreamChannel(process, in, inPipe, out, outPipe);
    }
View Full Code Here

                                                            prodEventBuffer,
                                                            emitterStats,
                                                            autoStartBuffer);

    //commn channels between reader and writer
    Pipe pipe = Pipe.open();
    Pipe.SinkChannel writerStream = pipe.sink();
    Pipe.SourceChannel readerStream = pipe.source();
    writerStream.configureBlocking(true);
    readerStream.configureBlocking(false);

    //Event writer - Relay in the real world
    int batchSize = input.getBatchSize() * eventSize;
 
View Full Code Here

    private SelectableChannel[] writable;

    public SelectorImpl(SelectorProvider selectorProvider) {
        super(selectorProvider);
        try {
            Pipe mockSelector = selectorProvider.openPipe();
            sink = mockSelector.sink();
            source = mockSelector.source();
            source.configureBlocking(false);
        } catch (IOException e) {
            // do nothing
        }
    }
View Full Code Here

    private int[] writableFDsToKeys;

    public SelectorImpl(SelectorProvider selectorProvider) {
        super(selectorProvider);
        try {
            Pipe mockSelector = selectorProvider.openPipe();
            sink = mockSelector.sink();
            source = mockSelector.source();
            sourcefd = ((FileDescriptorHandler) source).getFD();
            source.configureBlocking(false);

            readableFDs = new FileDescriptor[1];
            writableFDs = new FileDescriptor[0];
View Full Code Here

TOP

Related Classes of java.nio.channels.Pipe$SourceChannel

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.