views:

36

answers:

2

Pretty much like a queue,when the queue is full an new member wants to come in,just remove the first member at the head of the queue.

Is there such a default mechanism in windows?

If yes how can I do that in c/c++?

A: 

A WriteFile operation is affected by the wait mode of a pipe handle when there is insufficient space in the pipe's buffer. With a blocking-wait handle, the write operation cannot succeed until sufficient space is created in the buffer by a thread reading from the other end of the pipe. With a nonblocking-wait handle, the write operation returns a nonzero value immediately, without writing any bytes (for a message-type pipe) or after writing as many bytes as the buffer holds (for a byte-type pipe).

see

Anders K.
+1  A: 

No. Once written, bytes have to be read on the far end before bytes written later on the sending side can be read. It would not be much of a pipe otherwise. Any discard would have to be implemented on the receiving side. Or implement a write queue on the send side and discard as needed if you find yourself blocked on write.

Steve Townsend