本文整理了Java中org.jruby.Ruby.newErrnoEAGAINError
方法的一些代码示例,展示了Ruby.newErrnoEAGAINError
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ruby.newErrnoEAGAINError
方法的具体详情如下:
包路径:org.jruby.Ruby
类名称:Ruby
方法名:newErrnoEAGAINError
暂无
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceive(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
DatagramChannel channel = (DatagramChannel)getChannel();
ByteBuffer buf = ByteBuffer.allocate(length);
InetSocketAddress sender = (InetSocketAddress)channel.receive(buf);
if (sender == null) {
// noblocking receive
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("recvfrom(2) would block");
} else {
throw runtime.newErrnoEAGAINError("recvfrom(2) would block");
}
}
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(buf.array(), 0, buf.position()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceive(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
DatagramChannel channel = (DatagramChannel)getChannel();
ByteBuffer buf = ByteBuffer.allocate(length);
InetSocketAddress sender = (InetSocketAddress)channel.receive(buf);
if (sender == null) {
// noblocking receive
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("recvfrom(2) would block");
} else {
throw runtime.newErrnoEAGAINError("recvfrom(2) would block");
}
}
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(buf.array(), 0, buf.position()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public ByteList doReceiveNonblock(ThreadContext context, int length) {
Ruby runtime = context.runtime;
Channel channel = getChannel();
if (!(channel instanceof SelectableChannel)) {
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError(channel.getClass().getName() + " does not support nonblocking");
} else {
throw runtime.newErrnoEAGAINError(channel.getClass().getName() + " does not support nonblocking");
}
}
SelectableChannel selectable = (SelectableChannel)channel;
synchronized (selectable.blockingLock()) {
boolean oldBlocking = selectable.isBlocking();
try {
selectable.configureBlocking(false);
try {
return doReceive(context, length);
} finally {
selectable.configureBlocking(oldBlocking);
}
} catch(IOException e) {
throw runtime.newIOErrorFromException(e);
}
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public ByteList doReceiveNonblock(ThreadContext context, int length) {
Ruby runtime = context.runtime;
Channel channel = getChannel();
if (!(channel instanceof SelectableChannel)) {
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError(channel.getClass().getName() + " does not support nonblocking");
} else {
throw runtime.newErrnoEAGAINError(channel.getClass().getName() + " does not support nonblocking");
}
}
SelectableChannel selectable = (SelectableChannel)channel;
synchronized (selectable.blockingLock()) {
boolean oldBlocking = selectable.isBlocking();
try {
selectable.configureBlocking(false);
try {
return doReceive(context, length);
} finally {
selectable.configureBlocking(oldBlocking);
}
} catch(IOException e) {
throw runtime.newIOErrorFromException(e);
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceiveMulticast(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
byte[] buf2 = new byte[length];
DatagramPacket recv = new DatagramPacket(buf2, buf2.length);
MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
try {
ms.receive(recv);
} catch (IllegalBlockingModeException ibme) {
// MulticastSocket does not support nonblocking
// TODO: Use Java 7 NIO.2 DatagramChannel to do multicast
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking");
} else {
throw runtime.newErrnoEAGAINError("multicast UDP does not support nonblocking");
}
}
InetSocketAddress sender = (InetSocketAddress) recv.getSocketAddress();
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(recv.getData(), 0, recv.getLength()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
private IRubyObject doReceiveMulticast(Ruby runtime, int length, ReceiveTuple tuple) throws IOException {
byte[] buf2 = new byte[length];
DatagramPacket recv = new DatagramPacket(buf2, buf2.length);
MulticastSocket ms = this.multicastStateManager.getMulticastSocket();
try {
ms.receive(recv);
} catch (IllegalBlockingModeException ibme) {
// MulticastSocket does not support nonblocking
// TODO: Use Java 7 NIO.2 DatagramChannel to do multicast
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("multicast UDP does not support nonblocking");
} else {
throw runtime.newErrnoEAGAINError("multicast UDP does not support nonblocking");
}
}
InetSocketAddress sender = (InetSocketAddress) recv.getSocketAddress();
// see JRUBY-4678
if (sender == null) {
throw runtime.newErrnoECONNRESETError();
}
RubyString result = runtime.newString(new ByteList(recv.getData(), 0, recv.getLength()));
if (tuple != null) {
tuple.result = result;
tuple.sender = sender;
}
return result;
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod
public IRubyObject recv_nonblock(ThreadContext context, IRubyObject _length) {
Ruby runtime = context.runtime;
ByteList bytes = doReceiveNonblock(context, RubyNumeric.fix2int(_length));
if (bytes == null) {
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("recvfrom(2)");
} else {
throw runtime.newErrnoEAGAINError("recvfrom(2)");
}
}
return RubyString.newString(runtime, bytes);
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod
public IRubyObject recv_nonblock(ThreadContext context, IRubyObject _length) {
Ruby runtime = context.runtime;
ByteList bytes = doReceiveNonblock(context, RubyNumeric.fix2int(_length));
if (bytes == null) {
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("recvfrom(2)");
} else {
throw runtime.newErrnoEAGAINError("recvfrom(2)");
}
}
return RubyString.newString(runtime, bytes);
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod(name = "accept_nonblock")
public IRubyObject accept_nonblock(ThreadContext context) {
Ruby runtime = context.runtime;
RubyTCPSocket socket = new RubyTCPSocket(runtime, runtime.getClass("TCPSocket"));
Selector selector = null;
synchronized (ssc.blockingLock()) {
boolean oldBlocking = ssc.isBlocking();
try {
ssc.configureBlocking(false);
selector = SelectorFactory.openWithRetryFrom(runtime, SelectorProvider.provider());
boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT, 0);
if (!ready) {
// no connection immediately accepted, let them try again
throw runtime.newErrnoEAGAINError("Resource temporarily unavailable");
} else {
// otherwise one key has been selected (ours) so we get the channel and hand it off
socket.initSocket(context.runtime, new ChannelDescriptor(ssc.accept(), newModeFlags(runtime, ModeFlags.RDWR)));
return socket;
}
} catch(IOException e) {
throw SocketUtils.sockerr(context.runtime, "problem when accepting");
} finally {
try {
if (selector != null) selector.close();
} catch (Exception e) {
}
try {ssc.configureBlocking(oldBlocking);} catch (IOException ioe) {}
}
}
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
throw runtime.newErrnoEAGAINError("Resource temporarily unavailable");
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject[] args, boolean useException) {
IRubyObject value = getPartial(context, args, true);
if (value.isNil()) {
throw context.runtime.newEOFError();
}
if (value instanceof RubyString) {
RubyString str = (RubyString) value;
if (str.isEmpty()) {
Ruby ruby = context.runtime;
if (useException) {
if (ruby.is1_9()) {
throw ruby.newErrnoEAGAINReadableError("");
} else {
throw ruby.newErrnoEAGAINError("");
}
} else {
return ruby.fastNewSymbol("wait_readable");
}
}
}
return value;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
public IRubyObject doReadNonblock(ThreadContext context, IRubyObject[] args, boolean useException) {
IRubyObject value = getPartial(context, args, true);
if (value.isNil()) {
throw context.runtime.newEOFError();
}
if (value instanceof RubyString) {
RubyString str = (RubyString) value;
if (str.isEmpty()) {
Ruby ruby = context.runtime;
if (useException) {
if (ruby.is1_9()) {
throw ruby.newErrnoEAGAINReadableError("");
} else {
throw ruby.newErrnoEAGAINError("");
}
} else {
return ruby.fastNewSymbol("wait_readable");
}
}
}
return value;
}
代码示例来源:origin: org.kill-bill.billing/killbill-osgi-bundles-jruby
@JRubyMethod
public IRubyObject accept_nonblock(ThreadContext context) {
Ruby runtime = context.runtime;
SelectableChannel selectable = (SelectableChannel)channel;
synchronized (selectable.blockingLock()) {
boolean oldBlocking = selectable.isBlocking();
try {
selectable.configureBlocking(false);
try {
UnixSocketChannel socketChannel = ((UnixServerSocketChannel) channel).accept();
RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate"));
sock.channel = socketChannel;
sock.fpath = "";
sock.init_sock(context.runtime);
return sock;
} finally {
selectable.configureBlocking(oldBlocking);
}
} catch (IOException ioe) {
if (ioe.getMessage().equals("accept failed: Resource temporarily unavailable")) {
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("accept");
} else {
throw runtime.newErrnoEAGAINError("accept");
}
}
throw context.runtime.newIOErrorFromException(ioe);
}
}
}
代码示例来源:origin: com.ning.billing/killbill-osgi-bundles-jruby
@JRubyMethod
public IRubyObject accept_nonblock(ThreadContext context) {
Ruby runtime = context.runtime;
SelectableChannel selectable = (SelectableChannel)channel;
synchronized (selectable.blockingLock()) {
boolean oldBlocking = selectable.isBlocking();
try {
selectable.configureBlocking(false);
try {
UnixSocketChannel socketChannel = ((UnixServerSocketChannel) channel).accept();
RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate"));
sock.channel = socketChannel;
sock.fpath = "";
sock.init_sock(context.runtime);
return sock;
} finally {
selectable.configureBlocking(oldBlocking);
}
} catch (IOException ioe) {
if (ioe.getMessage().equals("accept failed: Resource temporarily unavailable")) {
if (runtime.is1_9()) {
throw runtime.newErrnoEAGAINReadableError("accept");
} else {
throw runtime.newErrnoEAGAINError("accept");
}
}
throw context.runtime.newIOErrorFromException(ioe);
}
}
}
内容来源于网络,如有侵权,请联系作者删除!