Thread: [Nutshell-devel] Basic class information : Byte Buffer.
Status: Planning
Brought to you by:
alexandream
From: Alexandre M. <ale...@gm...> - 2006-08-24 18:15:40
|
Keeping the batch of messages related to the class of the system. A ByteBuffer is a buffer used by the network pieces of our system, to keep track of incoming data until it can safely extract a message out of it. Here is its basic definition (somethings may vary as I already have an implemented version of this class at home, with no access to it right now). The ByteBuffer is a circular buffer, that can hold up to size bytes, wrapping around when needed, if possible. This is useful to hold received data and yet-to-send data. Heavily used by our sockets. ByteBuffer public: ByteBuffer(int size); virtual ~ByteBuffer(); insert(const ByteArray& source, int size); fetch(ByteArray& dest, int size); discard(int size); consume(ByteArray& dest, int size); // this is simply a fetch(); discard(); int getSize(); int getCapacity(); private: char* data; int size; int position; And there goes another piece of our class strucutre... a lecture brought to you by Yago Warner! Until I find out I missed something again, I'll rest.. .and work a bit more. Regards, Alexandre Moreira. |
From: Rodrigo C. <rc...@gm...> - 2006-08-24 19:24:48
|
On 8/24/06, Alexandre Moreira <ale...@gm...> wrote: > > Keeping the batch of messages related to the class of the system. > > A ByteBuffer is a buffer used by the network pieces of our system, to > keep track of incoming data until it can safely extract a message out > of it. Here is its basic definition (somethings may vary as I already > have an implemented version of this class at home, with no access to > it right now). > > The ByteBuffer is a circular buffer, that can hold up to size bytes, wrapping around when needed, if possible. > When needed or if possible? I guess I didn`t catch up that one.... Or you wrap around when needed or not.... What you do when it need but you can`t? Exception? Data loss? This is useful to hold > received data and yet-to-send data. Heavily used by our sockets. > ByteBuffer > public: > ByteBuffer(int size); > virtual ~ByteBuffer(); > insert(const ByteArray& source, int size); > fetch(ByteArray& dest, int size); > discard(int size); > consume(ByteArray& dest, int size); // this is simply a fetch(); > discard(); > int getSize(); > int getCapacity(); > private: > char* data; > int size; > int position; > > And there goes another piece of our class strucutre... a lecture > brought to you by Yago Warner! > > Until I find out I missed something again, I'll rest.. .and work a bit > more. > > Regards, > Alexandre Moreira. > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim= o > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > Nutshell-devel mailing list > Nut...@li... > https://lists.sourceforge.net/lists/listinfo/nutshell-devel > --=20 Abra=E7os, Rodrigo |
From: Alexandre M. <ale...@gm...> - 2006-08-24 19:43:28
|
2006/8/24, Rodrigo Coacci <rc...@gm...>: [...] > When needed or if possible? > I guess I didn`t catch up that one.... Or you wrap around when needed or > not.... > What you do when it need but you can`t? Exception? Data loss? > The Buffer, as a class outside of our system, when need to put data and can't find any room for it, will throw an exception. It is the job of the client class (our system, in this context) to get a buffer that is large enough for the data it wants to put there (in our case this will probably be "Two times the size of the larger message", but I will explain the why later). [...] Regards, Alexandre Moreira. |
From: Rodrigo C. <rc...@gm...> - 2006-08-26 16:43:18
|
Also whats the difference btwn getSize and getCapacity? On 8/24/06, Alexandre Moreira <ale...@gm...> wrote: > > 2006/8/24, Rodrigo Coacci <rc...@gm...>: > [...] > > When needed or if possible? > > I guess I didn`t catch up that one.... Or you wrap around when needed o= r > > not.... > > What you do when it need but you can`t? Exception? Data loss? > > > The Buffer, as a class outside of our system, when need to put data > and can't find any room for it, will throw an exception. It is the job > of the client class (our system, in this context) to get a buffer that > is large enough for the data it wants to put there (in our case this > will probably be "Two times the size of the larger message", but I > will explain the why later). > > [...] > > Regards, > Alexandre Moreira. > > ------------------------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronim= o > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D120709&bid=3D263057&dat= =3D121642 > _______________________________________________ > Nutshell-devel mailing list > Nut...@li... > https://lists.sourceforge.net/lists/listinfo/nutshell-devel > --=20 Abra=E7os, Rodrigo |
From: Alexandre M. <ale...@gm...> - 2006-08-28 16:01:58
|
2006/8/26, Rodrigo Coacci <rc...@gm...>: > Also whats the difference btwn getSize and getCapacity? > the Buffer may be partly filled. That way we need a way to learn its total size (getSize) and another way to find out how much space is there left in the buffer (getCapacity)... perhaps we can find some new names for these functions... don't know |