@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.init_sock(context.runtime, socketChannel, ""); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }
@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.channel = socketChannel; sock.fpath = ""; sock.init_sock(context.runtime); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }
@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.init_sock(context.runtime, socketChannel, ""); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }
@JRubyMethod public IRubyObject accept(ThreadContext context) { Ruby runtime = context.runtime; try { while (true) { // select loop to allow interrupting boolean ready = context.getThread().select(this, SelectionKey.OP_ACCEPT); if (!ready) { // we were woken up without being selected...poll for thread events and go back to sleep context.pollThreadEvents(); } else { UnixSocketChannel socketChannel = asUnixServer().accept(); RubyUNIXSocket sock = (RubyUNIXSocket)(Helpers.invoke(context, runtime.getClass("UNIXSocket"), "allocate")); sock.channel = socketChannel; sock.fpath = ""; sock.init_sock(context.runtime); return sock; } } } catch (IOException ioe) { throw context.runtime.newIOErrorFromException(ioe); } }