#include <StrMod/StreamFDModule.h>
Inheritance diagram for strmod::strmod::StreamFDModule:

Public Types | |
|
typedef lcore::enum_set< ErrorType, ErrRead, ErrFatal > | ErrorSet |
| Typedef for set of error types. | |
| enum | IOCheckFlags { CheckNone, CheckRead, CheckWrite, CheckBoth } |
| What directions is IO checked in? This is used for file descriptors that are open only for reading, or only for writing. More... | |
| enum | ErrorType { ErrRead, ErrWrite, ErrGeneral, ErrFatal } |
| What kinds of errors are possible? More... | |
Public Methods | |
| StreamFDModule (int fd, unievent::Dispatcher &disp, unievent::UnixEventRegistry &ureg, IOCheckFlags checkmask=CheckBoth) | |
| Constructs a StreamFDModule from an OS file descriptor. | |
| virtual | ~StreamFDModule () |
| Closes the associated file descriptor. | |
| virtual int | AreYouA (const lcore::ClassIdent &cid) const |
| Asks if a class is of a particular type, or publicly derived from that type. | |
| virtual bool | canCreate (int side) const |
| Can a plug be created on the given side? | |
| virtual bool | ownsPlug (const Plug *p) const |
| Does the module own this plug? | |
| virtual bool | deletePlug (Plug *p) |
| Please delete this plug. | |
| bool | hasErrorIn (ErrorType err) const throw () |
| Check for an error in the given category. | |
| bool | hasErrorIn (const ErrorSet &set) const throw () |
| Check for an error in one of the categories given by the set. | |
| void | onErrorIn (ErrorType err, const unievent::EventPtr &ev) throw () |
| Ask to post an event when the given error type happens. | |
| void | resetErrorIn (ErrorType err) throw () |
| Reset the error value for a particular category. | |
| const unievent::UNIXError & | getErrorIn (ErrorType err) const throw () |
| Get the error value for a particular category. | |
| void | setSendChunkOnEOF (bool newval) throw () |
| Set whether or not and EOFStrChunk is sent when an EOF is read. | |
| bool | getSendChunkOnEOF () throw () |
| Does this module send a chunk on EOF? | |
| void | setMaxChunkSize (size_t mbs) |
| Sets the maximum block size to be read in a single read operation. | |
| size_t | getMaxChunkSize () const |
| Returns the maximum block size to be read in a single read operation. | |
| size_t | getBestChunkSize () const |
| This returns the optimal IO blocksize for this descriptor. | |
| void | setMaxToBest () |
| Mostly equivalent to setMaxChunkSize(BestChunkSize()) If the value returned by BestChunkSize is an 'unreasonable' value such as less than 1024 (1k) bytes, or more than 65536 (64k) bytes, the value is set to the closest 'reasonable' value. | |
Static Public Attributes | |
| const STR_ClassIdent | identifier |
| A unique identifier for this class. | |
| const size_t | S_max_bytes_without_dispatch = 256U * 1024U |
| This is the maximum number of bytes to read or write without going back to the dispatcher. | |
Protected Methods | |
| virtual const lcore::ClassIdent * | i_GetIdent () const |
| Returns the class identifier for the class the object actually is. | |
| virtual Plug * | i_MakePlug (int side) |
| Makes a plug on the given side. | |
| virtual void | plugWrite (const StrChunkPtr &ptr) |
| Called by FPlug::i_Write. | |
| virtual const StrChunkPtr | plugRead () |
| Called by FPlug::i_Read. | |
| virtual void | doReadFD () |
| Read from fd into buffed_read_. | |
| virtual void | doWriteFD () |
| Write to fd from cur_write_, using the info in write_vec_. | |
| virtual void | writeEOF () |
| An EOF indication has been written. | |
| void | setErrorIn (ErrorType err, const unievent::UNIXError &errval) |
| Set an error in a particular category. | |
| void | eventRead () |
| Called by readev_ and resumeread_'s triggerEvent. | |
| void | eventWrite () |
| Called by writeev_ and resumewrite_'s triggerEvent. | |
| void | eventError () |
| Called by errorev_'s triggerEvent. | |
| void | eventResumeRead () |
| Called by resumeread_'s triggerEvent. | |
| void | eventResumeWrite () |
| Called by resumewrite_'s triggerEvent. | |
| int | getFD () const throw () |
| Get the file descriptor so a derived class can do something to it. | |
Friends | |
| class | FPlug |
| class | StreamFDModule::EvMixin |
| class | StreamFDModule::FDPollRdEv |
| class | StreamFDModule::FDPollWrEv |
| class | StreamFDModule::FDPollErEv |
| class | StreamFDModule::ResumeReadEv |
| class | StreamFDModule::ResumeWriteEv |
| class | MyPollEvent |
One side of this module is a UNIX file descriptor, and the other side is the plug. Everything written to the plug is written to the file descriptor, and everything read from the file descriptor is read from the plug.
There are (or will be) ways of asking for events to be posted when stuff happens that the StreamFDModule can't deal with directly, such has EOF, read or write errors, or unexpected file descriptor closings.
Definition at line 65 of file StreamFDModule.h.
|
|
What kinds of errors are possible?
Definition at line 98 of file StreamFDModule.h. |
|
|
What directions is IO checked in? This is used for file descriptors that are open only for reading, or only for writing.
Definition at line 90 of file StreamFDModule.h. |
|
||||||||||||||||||||
|
Constructs a StreamFDModule from an OS file descriptor.
Definition at line 798 of file StreamFDModule.cxx. |
|
|
Asks if a class is of a particular type, or publicly derived from that type. Overriden in every derived class (with a static identifier member) to compare against the identifier, then call the AreYouA methods of all the superclasses.
Reimplemented from strmod::strmod::StreamModule. Definition at line 323 of file StreamFDModule.h. |
|
|
Please delete this plug. Modules are supposed to own plugs, so you aren't supposed to delete them yourself. Returns false on failure. Failure could happen because module does not own the plug. Implements strmod::strmod::StreamModule. Definition at line 338 of file StreamFDModule.h. |
|
|
Read from fd into buffed_read_. Assumes that buffed_read_ is empty, that there are no read errors, no fatal errors, and that EOF has not been read. If the read returns '0' and the EOF on read flag (flags_.chunkeof, possibly set by setSendChunkOnEOF() ) is set, buffed_read_ will contain an EOFStrChunk. Definition at line 596 of file StreamFDModule.cxx. |
|
|
Write to fd from cur_write_, using the info in write_vec_. Assumes that cur_write_ isn't empty, that there are no write errors, no fatal errors, and that EOF has not been written. If cur_write_ is an EOFStrChunk, it will call writeEOF(). Definition at line 685 of file StreamFDModule.cxx. |
|
|
This returns the optimal IO blocksize for this descriptor. This returns the st_blksize member of the stat structure returned by fstat'ing the file descriptor. If the stat cannot be performed, or st_blksize is 0, a default value (most likely 4096) is returned. In a certain special case, if 0 < st_blksize < 64, 64 is returned. Definition at line 469 of file StreamFDModule.cxx. |
|
|
Returns the class identifier for the class the object actually is. Should always be overridden in any class that has a static identifier member. Reimplemented from strmod::strmod::StreamModule. Definition at line 233 of file StreamFDModule.h. |
|
|
Makes a plug on the given side. Guaranteed to never be called if canCreate would return false. Must NEVER return 0 (NULL). Implements strmod::strmod::StreamModule. Definition at line 367 of file StreamFDModule.h. |
|
||||||||||||
|
Ask to post an event when the given error type happens. Currently only one event per error type is allowed. If there is already an event for a particular error type, that event will be forgotten about and not posted. Definition at line 378 of file StreamFDModule.cxx. |
|
|
Reset the error value for a particular category. This does not work for the ErrFatal category. Definition at line 384 of file StreamFDModule.cxx. |
|
|
An EOF indication has been written. This function has to handle it. This function follows the template method pattern from Design Patterns. Do whatever is needed to write an EOF to the file descriptor for this module. Definition at line 777 of file StreamFDModule.cxx. |
|
|
This is the maximum number of bytes to read or write without going back to the dispatcher. If the socket on this class has enough data going through it to saturate the CPU, the StreamFDModule may never give the CPU to any of the other StreamFDModules unless it voluntarily gives it up after passing a certain amount of data. This is the constant that determines how much data is enough. This should possibly be a configurable value, but it isn't yet. If it is too low, you call back the dispatcher too often, and high bandwidth connections are handled slightly less efficiently than they could be. If it's too high you'll get choppy response. It's kinda like the multitasking timeslice value in an OS. Definition at line 124 of file StreamFDModule.h. |
1.3-rc1