本文整理了Java中java.nio.channels.Pipe.source()
方法的一些代码示例,展示了Pipe.source()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Pipe.source()
方法的具体详情如下:
包路径:java.nio.channels.Pipe
类名称:Pipe
方法名:source
[英]Returns the source channel of the pipe.
[中]返回管道的源通道。
代码示例来源:origin: wildfly/wildfly
final Pipe topPipe = Pipe.open();
try {
topPipe.source().configureBlocking(false);
topPipe.sink().configureBlocking(false);
final Pipe bottomPipe = Pipe.open();
try {
bottomPipe.source().configureBlocking(false);
bottomPipe.sink().configureBlocking(false);
final WorkerThread peerThread = getPeerThread(peer);
final SelectionKey topSourceKey = registerChannel(topPipe.source());
final SelectionKey topSinkKey = peerThread.registerChannel(topPipe.sink());
final SelectionKey bottomSourceKey = peerThread.registerChannel(bottomPipe.source());
final SelectionKey bottomSinkKey = registerChannel(bottomPipe.sink());
final NioPipeStreamConnection leftConnection = new NioPipeStreamConnection(this, bottomSourceKey, topSinkKey);
if (! ok) {
safeClose(bottomPipe.sink());
safeClose(bottomPipe.source());
if (! ok) {
safeClose(topPipe.sink());
safeClose(topPipe.source());
代码示例来源:origin: wildfly/wildfly
public ChannelPipe<StreamSourceChannel, StreamSinkChannel> createHalfDuplexPipe(final XnioIoFactory peer) throws IOException {
getWorker().checkShutdown();
final Pipe pipe = Pipe.open();
boolean ok = false;
try {
pipe.source().configureBlocking(false);
pipe.sink().configureBlocking(false);
final WorkerThread peerThread = getPeerThread(peer);
final SelectionKey readKey = registerChannel(pipe.source());
final SelectionKey writeKey = peerThread.registerChannel(pipe.sink());
final NioPipeStreamConnection leftConnection = new NioPipeStreamConnection(this, readKey, null);
final NioPipeStreamConnection rightConnection = new NioPipeStreamConnection(this, null, writeKey);
leftConnection.writeClosed();
rightConnection.readClosed();
final ChannelPipe<StreamSourceChannel,StreamSinkChannel> result = new ChannelPipe<StreamSourceChannel, StreamSinkChannel>(leftConnection.getSourceChannel(), rightConnection.getSinkChannel());
ok = true;
return result;
} finally {
if (! ok) {
safeClose(pipe.sink());
safeClose(pipe.source());
}
}
}
代码示例来源:origin: com.redhat.rhevm.api/rhevm-api-powershell-expectj
/**
* @return a channel from which stderr data produced by the spawn can be read, or
* null if there is no channel to stderr.
*/
Pipe.SourceChannel getStderrChannel() {
if (systemErr == null) {
return null;
}
return systemErr.source();
}
代码示例来源:origin: Refinitiv/Elektron-SDK
/**
* Returns the SelectableChannel of the queue that can be registered
* with a selector.
*
* @return SelectableChannel of the queue
*/
public SelectableChannel readChannel()
{
return _readPipe.source();
}
代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot
@Override
public void run(Selectable selectable) {
try {
wakeup.source().read(ByteBuffer.allocate(64));
} catch (IOException e) {
throw new RuntimeException(e);
}
expireSelectable(selectable);
}
代码示例来源:origin: org.apache.qpid/proton-j
@Override
public void run(Selectable selectable) {
try {
wakeup.source().read(ByteBuffer.allocate(64));
} catch (IOException e) {
throw new RuntimeException(e);
}
expireSelectable(selectable);
}
代码示例来源:origin: Refinitiv/Elektron-SDK
void pipeRead() throws IOException
{
if (_pipeWriteCount.decrementAndGet() == 0)
{
_pipeReadByte.clear();
_pipe.source().read(_pipeReadByte);
}
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Read from the pipe.
*/
public int read(byte[] dst, int offset, int length) throws IOException {
checkNotFlipped();
return pipe.source().read(ByteBuffer.wrap(dst, offset, length));
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Get a CodepointIterator that can iterate over unicode codepoints in this pipe. The pipe must be readable
*/
public CodepointIterator getIterator() {
checkNotFlipped();
return CodepointIterator.forReadableByteChannel(pipe.source(), charset);
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Get a CodepointIterator that can iterate over unicode codepoints in this pipe. The pipe must be readable
*/
public CodepointIterator getIterator(String charset) {
checkNotFlipped();
return CodepointIterator.forReadableByteChannel(pipe.source(), charset);
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Read from the pipe.
*/
public int read(ByteBuffer dst) throws IOException {
checkNotFlipped();
return pipe.source().read(dst);
}
代码示例来源:origin: org.terracotta/terracotta-l1-ee
public PipeSocket(Socket socket) throws IOException {
this.socket = socket;
this.inputPipe = Pipe.open();
this.outputPipe = Pipe.open();
this.outputPipe.source().configureBlocking(false);
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Get an inputstream that can read from this pipe. The Pipe must be readable
*/
public InputStream getInputStream() {
checkNotFlipped();
return new PipeChannelInputStream(this, Channels.newInputStream(pipe.source()));
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Get a reader that can reader from this pipe. The pipe must be readable
*/
public Reader getReader(String charset) {
checkNotFlipped();
return new PipeChannelReader(this, Channels.newReader(pipe.source(), charset));
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* Get a reader that can reader from this pipe. The pipe must be readable
*/
public Reader getReader() {
checkNotFlipped();
return new PipeChannelReader(this, Channels.newReader(pipe.source(), charset));
}
代码示例来源:origin: org.apache.abdera/abdera-i18n
/**
* True if the pipe is open
*/
public boolean isOpen() {
return pipe.sink().isOpen() || pipe.source().isOpen();
}
代码示例来源:origin: org.jruby/jruby-core
public void cleanup() throws IOException {
pipe.sink().close();
pipe.source().close();
}
}
代码示例来源:origin: org.terracotta/terracotta-ee
public PipeSocket(Socket socket) throws IOException {
this.socket = socket;
this.inputPipe = Pipe.open();
this.outputPipe = Pipe.open();
this.outputPipe.source().configureBlocking(false);
}
代码示例来源:origin: org.netbeans.api/org-jruby
@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 });
}
代码示例来源:origin: com.microsoft.azure.iot/proton-j-azure-iot
private Selectable timerSelectable() {
Selectable sel = selectable();
sel.setChannel(wakeup.source());
sel.onReadable(new TimerReadable());
sel.onExpired(new TimerExpired());
sel.onFree(new TimerFree());
sel.setReading(true);
sel.setDeadline(timer.deadline());
update(sel);
return sel;
}
内容来源于网络,如有侵权,请联系作者删除!