Package com.martiansoftware.nailgun
Class ReferenceCountedFileDescriptor
- java.lang.Object
-
- com.martiansoftware.nailgun.ReferenceCountedFileDescriptor
-
public class ReferenceCountedFileDescriptor extends java.lang.ObjectEncapsulates 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 booleanclosePendingprivate intfdprivate intfdRefCount
-
Constructor Summary
Constructors Constructor Description ReferenceCountedFileDescriptor(int fd)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description intacquire()voidclose()private voiddoClose()protected voidfinalize()voidrelease()
-
-
-
Method Detail
-
finalize
protected void finalize() throws java.io.IOException- Overrides:
finalizein 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
-
-