Class IOChannel

java.lang.Object
org.jruby.util.IOChannel
All Implemented Interfaces:
Closeable, AutoCloseable, Channel
Direct Known Subclasses:
IOChannel.IOReadableByteChannel, IOChannel.IOReadableWritableByteChannel, IOChannel.IOWritableByteChannel

public abstract class IOChannel extends Object implements Channel
Wrap an IO object in a Channel.
See Also:
  • Field Details

    • io

      protected final IRubyObject io
    • closeAdapter

      private final CallSite closeAdapter
    • respondToClosed

      private final RespondToCallSite respondToClosed
    • isClosedAdapter

      private final CallSite isClosedAdapter
    • runtime

      protected final Ruby runtime
  • Constructor Details

  • Method Details

    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Channel
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isOpen

      public boolean isOpen()
      Specified by:
      isOpen in interface Channel
    • read

      protected static int read(Ruby runtime, IRubyObject io, CallSite read, ByteBuffer dst) throws IOException
      Throws:
      IOException
    • write

      protected static int write(Ruby runtime, IRubyObject io, CallSite write, ByteBuffer src)
      Perform a write to the given IO-like object, using the given call site, and passing the contents of the given buffer. The buffer and its contents should not be referenced beyond the method's return.
      Parameters:
      runtime - the current runtime
      io - the target IO-like object
      write - the call site for making dynamic `write` calls
      src - the data to write
      Returns:
      the amount of data reported written by the dynamic `write` call
    • initReadSite

      protected CallSite initReadSite(String readMethod)
    • initWriteSite

      protected CallSite initWriteSite()