On 10/8/18 6:31 AM, Nicholas Wilson wrote:
On Monday, 8 October 2018 at 09:39:55 UTC, John Burton wrote:
My use case is sending data to a socket.

One part of my program generates blocks of bytes, and the socket part tries to send them to the socket and then removes from the queue the number that got sent.

[...]

Try searching for "circular buffer". I'm sure http://code.dlang.org/packages/iopipe has them in some form but I can't find them with a cursory search.

I called it a ring buffer:

http://schveiguy.github.io/iopipe/iopipe/buffer/RingBuffer.html

A couple notes here. The RingBuffer currently only works on Posix systems (I haven't had the motivation to dig into doing it on Windows, even though the docs mention VirtualAlloc). Also, the typical way one would use the RingBuffer is using rbufd in http://schveiguy.github.io/iopipe/iopipe/bufpipe/rbufd.html. But In the OP's case, if you aren't using iopipes to build a pipeline, that may prove more confusing than is worth (iopipe uses pull mechanisms exclusively, with somewhat novel mechanisms to enable buffered output). The RingBuffer type itself could be an easy-to-use mechanism for his use case.

Let me know if you decide to use it and need help. I'm always looking for more use cases for iopipe!

-Steve

Reply via email to