From 61d53b3246ae4e5869f1b65cc2ac1b35b76de1da Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Mon, 7 Jan 2019 16:29:09 +0100 Subject: erts: Add enif_select_read|write with 'msg_env' argument --- erts/doc/src/erl_nif.xml | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'erts/doc/src') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index 3fe6e00d57..34042cb4de 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -3063,6 +3063,11 @@ enif_map_iterator_destroy(env, &iter); {select, Obj, Ref, ready_input | ready_output}

ready_input or ready_output indicates if the event object is ready for reading or writing.

+

For complete control over the message format use the newer functions + enif_select_read or + enif_select_write + introduced in erts-11.0 (OTP-22.0).

+

Argument pid may be NULL to indicate the calling process.

Argument obj is a resource object obtained from enif_alloc_resource. @@ -3156,6 +3161,34 @@ if (retval & ERL_NIF_SELECT_STOP_CALLED) { + + int + enif_select_read(ErlNifEnv* env, ErlNifEvent event, void* obj, + const ErlNifPid* pid, ERL_NIF_TERM msg, ErlNifEnv* msg_env) + + int + enif_select_write(ErlNifEnv* env, ErlNifEvent event, void* obj, + const ErlNifPid* pid, ERL_NIF_TERM msg, ErlNifEnv* msg_env) + + Manage subscription on IO event. + +

These are variants of enif_select + where you can supply your own message term msg that will be sent to + the process instead of the predefined tuple {select,_,_,_}.

+

Argument msg_env must either be NULL or the environment of + msg allocated with + enif_alloc_env. If argument msg_env is + NULL the term msg will be copied, otherwise both + msg and msg_env will be invalidated by a successful call + to enif_select_read or enif_select_write.

+

Apart from the message format enif_select_read and + enif_select_write behaves exactly the same as enif_select with argument mode as + either ERL_NIF_SELECT_READ or ERL_NIF_SELECT_WRITE. To + cancel or close events use enif_select.

+ + + ErlNifPid * enif_self(ErlNifEnv* caller_env, ErlNifPid* pid) -- cgit v1.2.3