So, I feel that C ++ should have a good built-in solution for this, but I'm not sure what it is.
I need a queue (ideally thread safe, but I can wrap it myself during synchronization), which efficiently processes groups of bytes - allows me to read / write different sizes.
therefore, the interface looks, for example,
int dequeue(unsigned char *array, int bytesToRead)
int enqueue(unsigned char *array, int bytesToWrite)
I can write one myself without much difficulty, but it looks like it should be something that is easy to do from the shelf.
The best thing about STL is as if it could be a stringbuf - I would have to bind the sgetc / pubseekoff calls manually, but it looks like it would work.
I want to do this as a replacement for the current queue implementation, which is related to a performance issue; the read in this implementation is O (N) of the amount of data in the queue. (This is a very naive implementation - each dequeue copies an array of the remaining data in the queue.)
Additional requirements (I can implement them in the shell, if necessary): - I need to specify the maximum buffer size -Risk operations should retrieve all available data, if less data is available than was requested -Write operations should not do anything if the requested record exceeds the maximum size and returns a failure indicator
, :
1) stringbuf? / O (1) , ? (, O (n) .)
2) - , , ?
!