Package java.nio.channels

Examples of java.nio.channels.Pipe$SinkChannel


 
  @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 final NioPipeChannelImpl leftSide;
    private final NioPipeChannelImpl rightSide;

    NioPipeConnection(final NioXnio nioXnio, final IoHandler<? super StreamChannel> leftHandler, final IoHandler<? super StreamChannel> rightHandler, final Executor executor) throws IOException {
        final Pipe leftToRight = Pipe.open();
        final Pipe rightToLeft = Pipe.open();
        final Pipe.SourceChannel leftToRightSource = leftToRight.source();
        final Pipe.SinkChannel leftToRightSink = rightToLeft.sink();
        final Pipe.SourceChannel rightToLeftSource = rightToLeft.source();
        final Pipe.SinkChannel rightToLeftSink = leftToRight.sink();
        leftToRightSource.configureBlocking(false);
        leftToRightSink.configureBlocking(false);
        rightToLeftSource.configureBlocking(false);
        rightToLeftSink.configureBlocking(false);
View Full Code Here

    private final NioPipeSourceChannelImpl sourceSide;
    private final NioPipeSinkChannelImpl sinkSide;

    NioOneWayPipeConnection(final NioXnio nioXnio, final IoHandler<? super StreamSourceChannel> sourceHandler, final IoHandler<? super StreamSinkChannel> sinkHandler, final Executor executor) throws IOException {
        final Pipe pipe = Pipe.open();
        final Pipe.SourceChannel source = pipe.source();
        final Pipe.SinkChannel sink = pipe.sink();
        source.configureBlocking(false);
        sink.configureBlocking(false);
        final MBean mbean;
        try {
            mbean = new MBean();
View Full Code Here

    assertTrue(rdSz <= 0);
  }

  @Test
  public void testNewPipePartialReadSemantics() throws IOException {
    Pipe pipe = Pipe.open();
    int sz = 10;
    ByteBuffer buf = ByteBuffer.allocate(sz);
    pipe.sink().write(ByteBuffer.wrap("small".getBytes()));
    int rdSz = pipe.source().read(buf); // this operation blocks!
    assertTrue(rdSz <= sz);
  }
View Full Code Here

        TimeUnit.MILLISECONDS));
  }

  @Test
  public void testNewPipeBlockingSemantics() throws IOException {
    Pipe pipe = Pipe.open();
    ByteBuffer buf = ByteBuffer.allocate(10);
    assertTrue(pipe.source().isBlocking());
    pipe.source().configureBlocking(false);
    assertTrue(!pipe.source().isBlocking());
    int rdSz = pipe.source().read(buf); // this operation blocks!
    assertTrue(rdSz <= 0);
  }
View Full Code Here

TOP

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

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.