From 5036bf7d5006a6f1a4294b4a3b1f4120d39113ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20H=C3=B6gberg?= Date: Tue, 7 Nov 2017 09:31:24 +0100 Subject: Add enif_ioq_peek_head This introduces a way to retrieve erlang terms from NIF IO queues without having to resort to copying. OTP-14797 --- erts/doc/src/erl_nif.xml | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index ef3cdb89e9..23f0c66429 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -367,6 +367,8 @@ return term; enif_ioq_deq() enif_ioq_peek() + + enif_ioq_peek_head() enif_inspect_iovec() @@ -1683,8 +1685,7 @@ enif_inspect_iovec(env, max_elements, term, &tail, &iovec); Peek inside the IO Queue

Get the I/O queue as a pointer to an array of SysIOVecs. - It also returns the number of elements in iovlen. - This is the only way to get data out of the queue.

+ It also returns the number of elements in iovlen.

Nothing is removed from the queue by this function, that must be done with enif_ioq_deq.

The returned array is suitable to use with the Unix system @@ -1692,6 +1693,21 @@ enif_inspect_iovec(env, max_elements, term, &tail, &iovec); + + int + enif_ioq_peek_head(ErlNifEnv *env, ErlNifIOQueue *q, size_t *size, ERL_NIF_TERM *bin_term) + Peek the head of the IO Queue. + +

Get the head of the IO Queue as a binary term.

+

If size is not NULL, the size of the head is placed + there.

+

Nothing is removed from the queue by this function, that must be done + with enif_ioq_deq.

+

Returns true on success, or false if the queue is + empty.

+
+ + size_t enif_ioq_size(ErlNifIOQueue *q) -- cgit v1.2.3