From 4a736966eba5398a22697db6ca67e1e3dd3cd0f2 Mon Sep 17 00:00:00 2001 From: Lukas Larsson Date: Thu, 10 Dec 2015 10:58:33 +0100 Subject: erts: Add enif_cpu/now_time and enif_make_unique_integer --- erts/doc/src/erl_nif.xml | 201 ++++++++++++++++++++++++++++++----------------- 1 file changed, 127 insertions(+), 74 deletions(-) (limited to 'erts/doc') diff --git a/erts/doc/src/erl_nif.xml b/erts/doc/src/erl_nif.xml index be0e406b9c..e62f5792a5 100644 --- a/erts/doc/src/erl_nif.xml +++ b/erts/doc/src/erl_nif.xml @@ -591,6 +591,21 @@ typedef enum { + ErlNifUniqueInteger + +

An enumeration of the properties that can be requested from + + enif_unique_integer.

+ + ERL_NIF_UNIQUE_POSITIVE +

A positive integer

+ ERL_NIF_UNIQUE_MONOTONIC +

A + strictly + monotonically increasing integer corresponding to creation time

+
+
+ @@ -689,7 +704,49 @@ typedef enum { a number of repeated NIF-calls without the need to create threads. See also the warning text at the beginning of this document.

+ + + + + ErlNifTimeenif_convert_time_unit(ErlNifTime val, ErlNifTimeUnit from, ErlNifTimeUnit to) + Convert time unit of a time value + + +

Arguments:

+ + val + Value to convert time unit for. + from + Time unit of val. + to + Time unit of returned value. + +

Converts the val value of time unit from to + the corresponding value of time unit to. The result is + rounded using the floor function.

+

Returns ERL_NIF_TIME_ERROR if called with an invalid + time unit argument.

+

See also:

+ + ErlNifTime + ErlNifTimeUnit + +
+ + + ERL_NIF_TERMenif_cpu_time(ErlNifEnv *) + + +

Returns the CPU time in the same format as erlang:timestamp(). + The CPU time is the time the current logical cpu has spent executing since + some arbitrary point in the past. + If the OS does not support fetching of this value enif_cpu_time + invokes enif_make_badarg. +

+
+
+ intenif_equal_tids(ErlNifTid tid1, ErlNifTid tid2)

Same as erl_drv_equal_tids. @@ -1195,6 +1252,24 @@ typedef enum { Create an unsigned integer term

Create an integer term from an unsigned 64-bit integer.

+ + ERL_NIF_TERMenif_make_unique_integer(ErlNifEnv *env, ErlNifUniqueInteger properties) + + +

Returns a unique integer with the same properties as given by erlang:unique_integer/1.

+

env is the environment to create the integer in.

+

+ ERL_NIF_UNIQUE_POSITIVE and ERL_NIF_UNIQUE_MONOTONIC can + be passed as the second argument to change the properties of the + integer returned. It is possible to combine them by or:ing the + two values together. +

+

See also:

+ + ErlNifUniqueInteger + +
+
ERL_NIF_TERMenif_make_ulong(ErlNifEnv* env, unsigned long i) Create an integer term from an unsigned long int

Create an integer term from an unsigned long int.

@@ -1265,6 +1340,34 @@ enif_map_iterator_destroy(env, &iter); or false if the iterator is positioned at the head (before the first entry).

+ + + ErlNifTimeenif_monotonic_time(ErlNifTimeUnit time_unit) + Get Erlang Monotonic Time + + +

Arguments:

+ + time_unit + Time unit of returned value. + +

+ Returns + Erlang + monotonic time. Note that it is not uncommon with + negative values. +

+

Returns ERL_NIF_TIME_ERROR if called with an invalid + time unit argument, or if called from a thread that is not a + scheduler thread.

+

See also:

+ + ErlNifTime + ErlNifTimeUnit + +
+
+ ErlNifMutex *enif_mutex_create(char *name)

Same as erl_drv_mutex_create. @@ -1290,6 +1393,11 @@ enif_map_iterator_destroy(env, &iter);

Same as erl_drv_mutex_unlock.

+ ERL_NIF_TERMenif_now_time(ErlNifEnv *env) + +

Retuns an erlang:now() timestamp. + The enif_now_time function is deprecated.

+
ErlNifResourceType *enif_open_resource_type(ErlNifEnv* env, const char* module_str, const char* name, ErlNifResourceDtor* dtor, ErlNifResourceFlags flags, ErlNifResourceFlags* tried) @@ -1496,54 +1604,6 @@ enif_map_iterator_destroy(env, &iter);

Same as erl_drv_thread_self.

- intenif_tsd_key_create(char *name, ErlNifTSDKey *key) - -

Same as erl_drv_tsd_key_create. -

-
- voidenif_tsd_key_destroy(ErlNifTSDKey key) - -

Same as erl_drv_tsd_key_destroy. -

-
- void *enif_tsd_get(ErlNifTSDKey key) - -

Same as erl_drv_tsd_get. -

-
- voidenif_tsd_set(ErlNifTSDKey key, void *data) - -

Same as erl_drv_tsd_set. -

-
- - - - ErlNifTimeenif_monotonic_time(ErlNifTimeUnit time_unit) - Get Erlang Monotonic Time - - -

Arguments:

- - time_unit - Time unit of returned value. - -

- Returns - Erlang - monotonic time. Note that it is not uncommon with - negative values. -

-

Returns ERL_NIF_TIME_ERROR if called with an invalid - time unit argument, or if called from a thread that is not a - scheduler thread.

-

See also:

- - ErlNifTime - ErlNifTimeUnit - -
-
ErlNifTimeenif_time_offset(ErlNifTimeUnit time_unit) @@ -1571,33 +1631,26 @@ enif_map_iterator_destroy(env, &iter); - - ErlNifTimeenif_convert_time_unit(ErlNifTime val, ErlNifTimeUnit from, ErlNifTimeUnit to) - Convert time unit of a time value - - -

Arguments:

- - val - Value to convert time unit for. - from - Time unit of val. - to - Time unit of returned value. - -

Converts the val value of time unit from to - the corresponding value of time unit to. The result is - rounded using the floor function.

-

Returns ERL_NIF_TIME_ERROR if called with an invalid - time unit argument.

-

See also:

- - ErlNifTime - ErlNifTimeUnit - -
+ intenif_tsd_key_create(char *name, ErlNifTSDKey *key) + +

Same as erl_drv_tsd_key_create. +

+
+ voidenif_tsd_key_destroy(ErlNifTSDKey key) + +

Same as erl_drv_tsd_key_destroy. +

+
+ void *enif_tsd_get(ErlNifTSDKey key) + +

Same as erl_drv_tsd_get. +

+
+ voidenif_tsd_set(ErlNifTSDKey key, void *data) + +

Same as erl_drv_tsd_set. +

-
SEE ALSO -- cgit v1.2.3