79 int Poll(
double timeout);
180 unsigned Read(
void *ptr,
unsigned len);
185 unsigned Readv(
const iovec *iov,
int iovcnt);
197 unsigned Write(
const void *ptr,
unsigned len);
201 unsigned Writev(
const iovec *iov,
int iovcnt);
void Flush()
Tell the OS to flush any buffers it has. May not be supported for all file types. ...
int FD(int filed)
Set the current file descriptor.
bool IsBlocking() const
Test if the current file is in blocking or non blocking mode.
virtual void OnWriteable()
Called by Poll when it detects that the file is writeable.
bool Writeable(bool w)
Set that this file is currently writeable or not.
static int Poll(IteratorRef< FileHandle * > begin, IteratorRef< FileHandle * > end, double timeout)
poll a list of FileHandles for any activity and call the appropriate On method.
void SetBlocking(bool blocking)
Manipulate how the current file handles blocking.
void Close()
Close the file and reset the internal state.
AutoLock< PthreadMutex > ALock
virtual ~FileHandle()
Close the file descriptor. Use Reset if one wants to not close the file descriptor.
unsigned Writev(const iovec *iov, int iovcnt)
scatter gather io version of Write
A reference to an iterator.
bool Eof(bool e)
Set/reset the end of file condition.
FileHandle()
Construct a closed FileHandle.
bool Writeable() const
Gives the current writability status of the file.
void Reset()
Clear all internal state including the file descriptor! WARNING does not close the file! ...
bool Readable(bool r)
Set that the file is currently readable or not.
bool Readable() const
Gives the current readability status of the file.
FileHandle & operator=(const FileHandle &)
This allows the encapsulation of an arbitrary iterator of a specific type. This allows for non templa...
bool Good() const
Convenience method for testing if the file this FileHandle has is open and not at end of file...
unsigned Readv(const iovec *iov, int iovcnt)
scatter gather io version of Read
unsigned Read(void *ptr, unsigned len)
Read data from the file descriptor.
Generic file handle could be a file, or a socket or a device.
virtual void OnReadable()
Called by Poll when it detects that the file is readable.
Automatic locking on the stack.
unsigned Write(const void *ptr, unsigned len)
Write data to the file descriptor.