From 9c0ab3723c4cfb7f2d9061b661ae6a0331e72c8d Mon Sep 17 00:00:00 2001 From: Sverker Eriksson Date: Wed, 22 Feb 2017 12:01:37 +0100 Subject: Add docs for enif_compare_monitors and ErlNifMonitor --- erts/doc/src/erl_nif.xml | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-) (limited to 'erts') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index b31052287d..b0a632d2d6 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -675,6 +675,18 @@ typedef struct {

When receiving data from untrusted sources, use option ERL_NIF_BIN2TERM_SAFE.

+ ErlNifMonitor + +

This is an opaque data type that identifies a monitor.

+

The nif writer is to provide the memory for storing the + monitor when calling + enif_monitor_process. The + address of the data is not stored by the runtime system, so + ErlNifMonitor can be used as any other data, it + can be copied, moved in memory, forgotten, and so on. + To compare two monitors, + enif_compare_monitors must be used.

+
ErlNifPid

A process identifier (pid). In contrast to pid terms (instances of @@ -909,6 +921,21 @@ typedef enum { + + intenif_compare_monitors(const ErlNifMonitor + *monitor1, const ErlNifMonitor *monitor2) + Compare two monitors. + + +

Compares two ErlNifMonitors. + Can also be used to imply some artificial order on monitors, + for whatever reason.

+

Returns 0 if monitor1 and monitor2 are equal, + < 0 if monitor1 < monitor2, and + > 0 if monitor1 > monitor2.

+ + + void enif_cond_broadcast(ErlNifCond *cnd) @@ -1042,7 +1069,7 @@ typedef enum { Cancel a process monitor. -

Cancels a monitor created earlier with +

Cancels a monitor created earlier with enif_monitor_process. Argument obj is a pointer to the resource holding the monitor and *mon identifies the monitor.

Returns 0 if the monitor was successfully identified and removed. @@ -1050,6 +1077,7 @@ typedef enum { it was either

never created for this resource + already cancelled already triggered just about to be triggered by a concurrent thread @@ -2182,14 +2210,19 @@ enif_map_iterator_destroy(env, &iter);

Starts monitoring a process from a resource. When a process is monitored, a process exit results in a call to the provided - + down callback associated with the resource type.

Argument obj is pointer to the resource to hold the monitor and *target_pid identifies the local process to be monitored.

If mon is not NULL, a successful call stores the - identity of the monitor in the struct pointed to by mon. - This identifier is used to refer to the monitor for later removal or - compare. A monitor is automatically removed when it triggers or when + identity of the monitor in the + ErlNifMonitor + struct pointed to by mon. This identifier is used to refer to the + monitor for later removal with + enif_demonitor_process + or compare with + enif_compare_monitors. + A monitor is automatically removed when it triggers or when the resource is deallocated.

Returns 0 on success, < 0 if no down callback is provided, and > 0 if the process is no longer alive.

-- cgit v1.2.3