Documentation ¶
Overview ¶
Package rc provides reference counted file descriptors.
FD is a low level construct, and is useful only under very specific, rare circumstances. More often than not, callers should use the standard library os package to manage raw file descriptors instead.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUninitializedFD is the error returned by FD methods when called // on a file descriptor which has not been initialized. ErrUninitializedFD = errors.New("rc: use of uninitialized file descriptor") // ErrClosedFD is the error returned by FD methods when called on // a file descriptor which has been closed. ErrClosedFD = errors.New("rc: use of closed file descriptor") // ErrMultipleInit is the error returned by (*FD).Init when called // for at least the second time on a specific FD. ErrMultipleInit = errors.New("rc: multiple calls to (*FD).Init") )
var CloseFunc = unix.Close
CloseFunc hooks the close(2) system call.
Functions ¶
This section is empty.
Types ¶
type FD ¶
type FD struct {
// contains filtered or unexported fields
}
FD is a reference counted file descriptor.
The zero value for FD is not usable. Values of type FD must be initialized by calling the Init method, and must not be copied.
Once initialized, it is safe to call methods on an FD from multiple goroutines.
Once an FD is closed, its methods return errors, and it may not be re-initialized.
func (*FD) Close ¶
Close waits for the reference count associated with the FD to reach zero, unsets the finalizer associated with fd, then closes the file descriptor.
func (*FD) Decref ¶
func (fd *FD) Decref()
Decref decrements the reference count associated with the FD. Each call to Decref must occur after a corresponding call to Incref.