Writer and FIFOs

15 views
Skip to first unread message

Malcolm Matalka

unread,
Sep 20, 2015, 3:53:17 PM9/20/15
to ocaml...@googlegroups.com
I'm wondering if Writer gives any guarantees around writes to FIFOs.
Specifically, there is a value [PIPE_BUF] that defines how large of a
write one can do to a FIFO with the guarantee of it being atomic. I am
working on an async program that is pushing data around using FIFOs, do
I have to do anything special to ensure that Writer is always doing the
system calls in batches of [PIPE_BUF]. Perhaps if I do a write and
'flushed' write after?

On the same topic, is Writer making use of [writev] under the hood?

Thanks,
/Malcolm

Stephen Weeks

unread,
Sep 22, 2015, 5:25:06 PM9/22/15
to ocaml...@googlegroups.com
> do I have to do anything special to ensure that Writer is always
> doing the system calls in batches of [PIPE_BUF].

Yes. Writer doesn't do anything to respect PIPE_BUF.

> Perhaps if I do a write and 'flushed' write after?

If you make a sequence of calls to [Writer.write] and then wait on
[Writer.flushed], then Writer will make a single system call for all
of the writes. It will then fill the result of [Writer.flushed], and
you can continue.

> On the same topic, is Writer making use of [writev] under the hood?

Yes, although the vector will be of length one in the situation above.
Reply all
Reply to author
Forward
0 new messages