1. The prior level of the 'write' thread should be lower than the 'send' thread as possible.2. The buffer looks like a stack, so you can set a maximum stack size for prevent overflow for the buffer area. for example: if the buffer was 10M, the maximum stack size would be 10M. this means that you should record the change of the stack size when the 'write' thread constantly write data into the buffer, and the 'send' thread constantly send data to client. Once the current stack size is equivalent or greater than 10M then the 'write' thread should be set to wait until the size of is down. PS. Using message or event to do the wait that should be better.
if the buffer was 10M, the maximum stack size would be 10M.
this means that you should record the change of the stack size when the 'write' thread constantly write data into the buffer, and the 'send' thread constantly send data to client.
Once the current stack size is equivalent or greater than 10M then the 'write' thread should be set to wait until the size of is down.
PS. Using message or event to do the wait that should be better.
[email protected],
发mail也可以