Package java.nio.channels

Examples of java.nio.channels.Pipe.source()


        final AtomicReference<Throwable> failure = new AtomicReference<Throwable>();
        final AtomicBoolean complete = new AtomicBoolean();

        final Pipe pipe = Pipe.open();
        pipe.source().configureBlocking(false);
        final SelectionKey key = pipe.source().register(selector, SelectionKey.OP_READ);

        Thread thread = new Thread() {
            public void run() {
                try {
                    // make sure to call key.cancel() while the main thread is selecting
View Full Code Here


  /**
   * @tests java.nio.channels.Pipe#source()
   */
  public void test_source() throws IOException {
    Pipe pipe = Pipe.open();
    SourceChannel source = pipe.source();
    assertTrue(source.isBlocking());
  }

}

View Full Code Here

        // 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) {
View Full Code Here

    public static IRubyObject pipe19(ThreadContext context, IRubyObject recv, IRubyObject modes) {
        Ruby runtime = context.runtime;
        try {
            Pipe pipe = Pipe.open();

            RubyIO source = new RubyIO(runtime, pipe.source());
            source.setEncodingFromOptions(EncodingOption.getEncodingOptionFromString(runtime, modes.toString()));
            RubyIO sink = new RubyIO(runtime, pipe.sink());

//            Encoding ascii8bit = context.runtime.getEncodingService().getAscii8bitEncoding();
//            sink.setupReadWriteEncodings(context, ascii8bit, ascii8bit);
View Full Code Here

    }

    public PipeImpl() throws IOException {
        if (useNative) {
            Pipe pipe = Pipe.open();
            source = pipe.source();
            sink = pipe.sink();

        } else {
            PipedInputStream pipedIn = new PipedInputStream();
            try {
View Full Code Here

                    e.printStackTrace();
                }
            }
        });

        final Parsed<SBDInfo> parsed = SBDInfo.readFrom(pipe.source(), FEC_PARAMS);

        if (valid) {
            assertEquals(info, parsed.value());
        }
        else {
View Full Code Here

                    e.printStackTrace();
                }
            }
        });

        final Parsed<FECParameters> parsed = FECParameters.readFrom(pipe.source());

        assertEquals(PARAMS, parsed.value());
    }
}
View Full Code Here

  selector = Selector.open();

  Pipe pipe = Pipe.open();
  wakeupPipeSink = pipe.sink();
  wakeupPipeSource = pipe.source();
  wakeupPipeSource.configureBlocking(false);
  wakeupPipeKey = wakeupPipeSource.register(selector,
              SelectionKey.OP_READ);

  for (int i = 0; i < concurrency; i++) {
View Full Code Here

    final Future<Exception> f = taskPool.submit(task);
    taskPool.shutdown();
    Exception e1 = null;
    Exception e2 = null;
    try {
      this.c2.convert(Channels.newInputStream(pipe.source()), out,
          params2);
      e1 = f.get();
    } catch (final Exception e) {
      e2 = e;
    }
View Full Code Here

    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

TOP
Copyright © 2018 www.massapi.com. 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.