當前位置: 首頁>>代碼示例>>Java>>正文


Java Pipe.source方法代碼示例

本文整理匯總了Java中java.nio.channels.Pipe.source方法的典型用法代碼示例。如果您正苦於以下問題:Java Pipe.source方法的具體用法?Java Pipe.source怎麽用?Java Pipe.source使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.nio.channels.Pipe的用法示例。


在下文中一共展示了Pipe.source方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getImagesData

import java.nio.channels.Pipe; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public ReadableByteChannel getImagesData() {

	// Leverage the raw frame decoder as input to the colour decoder
	Pipe pipe = null;
	try {
		pipe = Pipe.open();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
	decoderthreadpool.execute(new ColourFrameDecoder(getRawImageData(), pipe.sink()));
	return pipe.source();
}
 
開發者ID:Cr0s,項目名稱:JavaRA,代碼行數:19,代碼來源:WsaFileCNC.java

示例2: main

import java.nio.channels.Pipe; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
  Pipe pipe = Pipe.open();

  Pipe.SinkChannel sinkChannel = pipe.sink();
  Pipe.SourceChannel sourceChannel = pipe.source();
  String newData = "New String to write to file..." + System.currentTimeMillis();
  ByteBuffer buf = ByteBuffer.allocate(48);
  buf.clear();
  buf.put(newData.getBytes());
  buf.flip();

  ByteBuffer bufread = ByteBuffer.allocate(48);

  while (buf.hasRemaining()) {
    sinkChannel.write(buf);
    int bytesRead = sourceChannel.read(bufread);
    System.out.println(bytesRead);
  }

}
 
開發者ID:whyDK37,項目名稱:pinenut,代碼行數:21,代碼來源:PipeTest.java

示例3: setup

import java.nio.channels.Pipe; //導入方法依賴的package包/類
/**
 * Creates a mock input stream which send some data every SMALL_TIMEOUT ms.
 */
@Before
public void setup() throws Exception {
    mock = TestUtils.mockInputStream(text);
    final Pipe pipe = Pipe.open();
    input = new SingleInputExpect(
            pipe.source(),
            pipe.sink(),
            mock.getStream(),
            Charset.defaultCharset(),
            null,
            null,
            DEFAULT_BUFFER_SIZE,
            false);
    executor = Executors.newSingleThreadExecutor();
    input.start(executor);
    mock.waitUntilReady();
}
 
開發者ID:Alexey1Gavrilov,項目名稱:ExpectIt,代碼行數:21,代碼來源:MatcherTest.java

示例4: getRawImageData

import java.nio.channels.Pipe; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public ReadableByteChannel getRawImageData() {

	Pipe pipe;
	try {
		pipe = Pipe.open();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
	decoderthreadpool.execute(new RawFrameDecoder(
			new DuplicateReadOnlyByteChannel(bytechannel), pipe.sink()));
	return pipe.source();
}
 
開發者ID:Cr0s,項目名稱:JavaRA,代碼行數:19,代碼來源:WsaFileCNC.java

示例5: getImagesData

import java.nio.channels.Pipe; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public ReadableByteChannel getImagesData() {

	Pipe pipe = null;
	try {
		pipe = Pipe.open();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
	decoderthreadpool.execute(new ImageDataDecoder(
			new DuplicateReadOnlyByteChannel(bytechannel), pipe.sink()));
	return pipe.source();
}
 
開發者ID:Cr0s,項目名稱:JavaRA,代碼行數:19,代碼來源:VqaFile.java

示例6: getSoundData

import java.nio.channels.Pipe; //導入方法依賴的package包/類
/**
 * {@inheritDoc}
 */
@Override
public ReadableByteChannel getSoundData() {
	Pipe pipe = null;
	
	try {
		pipe = Pipe.open();
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
		return null;
	}
	
	decoderthreadpool.execute(new SoundDataDecoder(
			new DuplicateReadOnlyByteChannel(bytechannel), pipe.sink()));
	return pipe.source();
}
 
開發者ID:Cr0s,項目名稱:JavaRA,代碼行數:20,代碼來源:VqaFile.java

示例7: wrap

import java.nio.channels.Pipe; //導入方法依賴的package包/類
public static SourceChannel wrap(InputStream in) throws IOException {
    Pipe pipe = Pipe.open();
    new EchoInputStreamWrapper(in, pipe.sink()).start();
    SourceChannel result = pipe.source();
    result.configureBlocking(false);
    return result;
}
 
開發者ID:apache,項目名稱:qpid-proton-j,代碼行數:8,代碼來源:EchoInputStreamWrapper.java

示例8: open

import java.nio.channels.Pipe; //導入方法依賴的package包/類
private synchronized void open() throws IOException {
  if (inboundSource == null) {
    SelectorProvider provider = SelectorProvider.provider();
    Pipe inboundPipe = provider.openPipe();
    inboundSource = inboundPipe.source();
    inboundSink = inboundPipe.sink();
    Pipe outboundPipe = provider.openPipe();
    outboundSource = outboundPipe.source();
    outboundSink = outboundPipe.sink();
  }
}
 
開發者ID:FIXTradingCommunity,項目名稱:silverflash,代碼行數:12,代碼來源:PipeTransport.java

示例9: createNonBlockingChannel

import java.nio.channels.Pipe; //導入方法依賴的package包/類
private Pipe.SourceChannel createNonBlockingChannel(byte[] content) throws IOException {
    Pipe pipe = Pipe.open();
    WritableByteChannel sinkChannel = pipe.sink();
    sinkChannel.write(ByteBuffer.wrap(content));
    Pipe.SourceChannel sourceChannel = pipe.source();
    sourceChannel.configureBlocking(false);
    return sourceChannel;
}
 
開發者ID:Sellegit,項目名稱:j2objc,代碼行數:9,代碼來源:ChannelsTest.java

示例10: test_source

import java.nio.channels.Pipe; //導入方法依賴的package包/類
/**
 * @tests java.nio.channels.Pipe#source()
 */
@TestTargetNew(
    level = TestLevel.COMPLETE,
    notes = "",
    method = "source",
    args = {}
)
public void test_source() throws IOException {
    Pipe pipe = Pipe.open();
    SourceChannel source = pipe.source();
    assertTrue(source.isBlocking());
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:15,代碼來源:PipeTest.java

示例11: prepareEngines

import java.nio.channels.Pipe; //導入方法依賴的package包/類
void prepareEngines() throws IOException {
    Pipe clientSendPipe = Pipe.open();
    Pipe serverSendPipe = Pipe.open();

    SinkChannel clientSink = clientSendPipe.sink();
    SourceChannel serverSource = clientSendPipe.source();
    SinkChannel serverSink = serverSendPipe.sink();
    SourceChannel clientSource = serverSendPipe.source();

    clientEngine = new HandshakeHandler(true, clientSource, clientSink);
    serverEngine = new HandshakeHandler(false, serverSource, serverSink);
}
 
開發者ID:keplersj,項目名稱:In-the-Box-Fork,代碼行數:13,代碼來源:SSLEngineTest.java

示例12: startWorker

import java.nio.channels.Pipe; //導入方法依賴的package包/類
private static ReadableByteChannel startWorker (int reps)
	throws Exception
{
	Pipe pipe = Pipe.open();
	Worker worker = new Worker (pipe.sink(), reps);

	worker.start();

	return (pipe.source());
}
 
開發者ID:jt120,項目名稱:nio,代碼行數:11,代碼來源:PipeTest.java

示例13: EpollSelectorImpl

import java.nio.channels.Pipe; //導入方法依賴的package包/類
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();

        keyFDs = new int[1];
        readyFDs = new int[1];
        readyOps = new int[1];

        // register sink channel
        keyFDs[0] = resolveFD(fileDescriptorClass, sourcefd);
        keys[0] = source.keyFor(this);
        epollFD = prepare();

        keysCount = 1;

        quickMap.put(keyFDs[0], (EpollSelectionKeyImpl) keys[0]);
        addFileDescriptor(epollFD, 1, keyFDs[0]);

    } catch (IOException e) {
        // do nothing
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:30,代碼來源:EpollSelectorImpl.java

示例14: SelectorImpl

import java.nio.channels.Pipe; //導入方法依賴的package包/類
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];
        keysToReadableFDs = new int[1];
        keysToWritableFDs = new int[0];
        readableFDsToKeys = new int[1];
        writableFDsToKeys = new int[0];

        // register sink channel
        readableFDs[0] = sourcefd;
        keys[0] = (SelectionKeyImpl) source.keyFor(this);

        // index it
        keysToReadableFDs[0] = 0;
        readableFDsToKeys[0] = 0;

        lastKeyIndex = 0;
        readableKeysCount = 1;
    } catch (IOException e) {
        // do nothing
    }
}
 
開發者ID:shannah,項目名稱:cn1,代碼行數:31,代碼來源:SelectorImpl.java

示例15: NBCircularIOStream

import java.nio.channels.Pipe; //導入方法依賴的package包/類
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);
}
 
開發者ID:indeedeng,項目名稱:imhotep,代碼行數:9,代碼來源:NBCircularIOStream.java


注:本文中的java.nio.channels.Pipe.source方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。