Class ReferenceCountedFileDescriptor


  • public class ReferenceCountedFileDescriptor
    extends java.lang.Object
    Encapsulates a file descriptor plus a reference count to ensure close requests only close the file descriptor once the last reference to the file descriptor is released. If not explicitly closed, the file descriptor will be closed when this object is finalized.
    • Field Detail

      • fd

        private int fd
      • fdRefCount

        private int fdRefCount
      • closePending

        private boolean closePending
    • Constructor Detail

      • ReferenceCountedFileDescriptor

        public ReferenceCountedFileDescriptor​(int fd)
    • Method Detail

      • finalize

        protected void finalize()
                         throws java.io.IOException
        Overrides:
        finalize in class java.lang.Object
        Throws:
        java.io.IOException
      • acquire

        public int acquire()
      • release

        public void release()
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • close

        public void close()
                   throws java.io.IOException
        Throws:
        java.io.IOException
      • doClose

        private void doClose()
                      throws java.io.IOException
        Throws:
        java.io.IOException