[Nutshell-devel] Network Class Information : DataSender and DataSendSource
Status: Planning
Brought to you by:
alexandream
From: Alexandre M. <ale...@gm...> - 2006-09-13 20:06:22
|
Continuing the latest series of class description for the project (yes, I know this all came rather quickly, but they don't allow me to really work at my work so... I play). These are much simpler class (yes, it can get simpler than those last two). You may have noticed that the last bit of information only really handled (efficiently) receiving data (using onWriteReady to actually write something wouldn't work since we would need to ... hmm ... actually HAVE something to send before that). So, these companion classes also work inside our network package to make the communication flow. As the IoSelector, the DataSender runs in a separate thread (yes, it is yet another thread). This may seem odd but hey, now we have full-duplex writing/reading from the same client code without too much hassle, and I can only hope that this won't hurt performance. The DataSender is just a thread that (unsurprisingly) reads from a DataSendSource and writes it to the ioChannel specified. And a DataSendSource is just... well... just an interface actually, but in our framework it will hold a few queues and do the job of handling who should be sent when. There they go: DataSender public: DataSender( DataSendSource & source ) void operator()(void) // to make it run as a thread. void stop(void) // used to stop the main loop in the thread. private DataSendSource& source; bool shouldStop; Along with it goes this class (an interface actually, but C++ is not silly enough to make these differences) DataSendSource //this is an interface public: virtual ByteBuffer * fetchData( int32& ioChannel ) = 0; void onSendError( int32 ioChannel, in32 error ) = 0; // The ioChannel in fetchData is actually an "out parameter"... unfortunately we cannot return multiple values and well.. I didn't felt like creating an structure just for that. I think that is enough for now. Anything you wanna know, I'm open for debates. Cheers, Alexandre Moreira. PS: It probably means nothing until now,since the "glue" part is not there yet. |