Package java.nio.channels

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


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

            fileDescriptorClass = sourcefd.getClass();
View Full Code Here


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

    final BasicThreadingContext threading = BasicThreadingContext.create (this, exceptions, exceptions.catcher);
    Assert.assertTrue (threading.initialize (BasicComponentTest.defaultPollTimeout));
    final BasicCallbackReactor reactor = BasicCallbackReactor.create (threading, exceptions);
    Assert.assertTrue (reactor.initialize (BasicComponentTest.defaultPollTimeout));
    final DefaultChannelMessageCoder coder = DefaultChannelMessageCoder.defaultInstance;
    final BasicChannel channel = BasicChannel.create (pipe.source (), pipe.sink (), coder, reactor, threading, exceptions);
    final BasicComponent component = BasicComponent.create (reactor, exceptions);
    Assert.assertTrue (channel.initialize (BasicComponentTest.defaultPollTimeout));
    Assert.assertTrue (component.initialize (BasicComponentTest.defaultPollTimeout));
    final ComponentController componentController = component.getController ();
    final ComponentCallbacks componentCallbacksProxy = reactor.createProxy (ComponentCallbacks.class);
View Full Code Here

    final BasicThreadingContext threading = BasicThreadingContext.create (this, exceptions, exceptions.catcher);
    Assert.assertTrue (threading.initialize (BasicChannelTest.defaultPollTimeout));
    final BasicCallbackReactor reactor = BasicCallbackReactor.create (threading, exceptions);
    Assert.assertTrue (reactor.initialize (BasicChannelTest.defaultPollTimeout));
    final DefaultChannelMessageCoder coder = DefaultChannelMessageCoder.defaultInstance;
    final BasicChannel channel = BasicChannel.create (pipe.source (), pipe.sink (), coder, reactor, threading, exceptions);
    Assert.assertTrue (channel.initialize (BasicChannelTest.defaultPollTimeout));
    final ChannelController channelController = channel.getController ();
    final ChannelCallbacks channelCallbacksProxy = reactor.createProxy (ChannelCallbacks.class);
    Assert.assertTrue (channelController.bind (channelCallbacksProxy).await (BasicChannelTest.defaultPollTimeout));
    final QueueingChannelCallbacks channelCallbacks = QueueingChannelCallbacks.create (channelController, exceptions);
View Full Code Here

    environment.transcript.traceDebugging ("creating pipes...");
    final Pipe inputPipe = Pipe.open ();
    final Pipe outputPipe = Pipe.open ();
    environment.transcript.traceDebugging ("creating pipers...");
    final Piper inputPiper = new Piper (Channels.newChannel (inputStream), inputPipe.sink (), environment.threading, environment.exceptions);
    final Piper outputPiper = new Piper (outputPipe.source (), Channels.newChannel (outputStream), environment.threading, environment.exceptions);
    environment.transcript.traceDebugging ("creating coder...");
    final DefaultChannelMessageCoder coder = DefaultChannelMessageCoder.create ();
    environment.transcript.traceDebugging ("creating channel...");
    final BasicChannel channel = BasicChannel.create (inputPipe.source (), outputPipe.sink (), coder, environment.reactor, environment.threading, environment.exceptions);
    environment.transcript.traceDebugging ("initializing channel...");
View Full Code Here

    Assert.assertTrue (threading.initialize (AbacusTest.defaultPollTimeout));
    final BasicCallbackReactor reactor = BasicCallbackReactor.create (threading, exceptions);
    Assert.assertTrue (reactor.initialize (AbacusTest.defaultPollTimeout));
    final DefaultChannelMessageCoder coder = DefaultChannelMessageCoder.defaultInstance;
    final BasicChannel serverChannel = BasicChannel.create (pipe1.source (), pipe2.sink (), coder, reactor, threading, exceptions);
    final BasicChannel clientChannel = BasicChannel.create (pipe2.source (), pipe1.sink (), coder, reactor, threading, exceptions);
    final BasicComponent serverComponent = BasicComponent.create (reactor, exceptions);
    final BasicComponent clientComponent = BasicComponent.create (reactor, exceptions);
    Assert.assertTrue (serverChannel.initialize (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (clientChannel.initialize (AbacusTest.defaultPollTimeout));
    Assert.assertTrue (serverComponent.initialize (AbacusTest.defaultPollTimeout));
View Full Code Here

  @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

  @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

  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);
  }

  @Test
View Full Code Here

    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);
  }

  @Test
  public void testNewPipePartialReadSemantics() throws IOException {
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.