Package com.martiansoftware.nailgun
Class ReferenceCountedFileDescriptor
- java.lang.Object
-
- com.martiansoftware.nailgun.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 Summary
Fields Modifier and Type Field Description private boolean
closePending
private int
fd
private int
fdRefCount
-
Constructor Summary
Constructors Constructor Description ReferenceCountedFileDescriptor(int fd)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
acquire()
void
close()
private void
doClose()
protected void
finalize()
void
release()
-
-
-
Method Detail
-
finalize
protected void finalize() throws java.io.IOException
- Overrides:
finalize
in classjava.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
-
-