process (ex_stdlib v0.2.0)
View SourceProcess utilities module inspired by Elixir's Process module.
This module provides convenient functions for working with processes, building on top of Erlang's built-in process functionality.
Summary
Functions
Returns true if the process is alive, false otherwise.
Cancels a timer created by send_after/3 or send_interval/3.
Removes the monitor identified by the given reference.
Removes the monitor identified by the given reference with options.
Erases the entire process dictionary.
Erases the given key from the process dictionary.
Terminates the given process with the given reason.
Sets a process flag for the current process.
Returns the process dictionary of the current process.
Returns the value associated with the given key in the process dictionary.
Returns all keys in the process dictionary.
Returns all keys associated with the given value in the process dictionary.
Returns the group leader of the current process.
Sets the group leader of the given process.
Returns information about the current process.
Returns information about the given process.
Returns specific information about the given process.
Monitors the given process and returns the monitor reference.
Stores a key-value pair in the process dictionary.
Registers the current process under the given name.
Returns a list of all registered process names.
Sends a message to a process after the given time.
Sends a message to a process repeatedly at the given interval.
Sleeps the current process for the given number of milliseconds.
Unregisters the given name.
Returns the PID of the process registered under the given name.
Types
-type monitor_option() :: {alias, reply_demonitor | explicit_unalias}.
-type process_flag() ::
trap_exit | error_handler | min_heap_size | min_bin_vheap_size | priority | save_calls |
sensitive | max_heap_size.
-type process_info_item() ::
registered_name | status | links | monitors | monitored_by | trap_exit | error_handler |
priority | group_leader | total_heap_size | heap_size | stack_size | reductions |
garbage_collection | suspending | current_function | current_location | current_stacktrace |
initial_call | dictionary | message_queue_len | messages | binary | memory.
Functions
-spec alive(process_ref()) -> boolean().
Returns true if the process is alive, false otherwise.
This is equivalent to is_process_alive/1 but with a more convenient name.
-spec cancel_timer(reference()) -> non_neg_integer() | false.
Cancels a timer created by send_after/3 or send_interval/3.
This is a convenience wrapper around erlang:cancel_timer/1.
-spec demonitor(reference()) -> true.
Removes the monitor identified by the given reference.
This is equivalent to demonitor(MonitorRef, [flush]).
-spec demonitor(reference(), [flush | info]) -> true.
Removes the monitor identified by the given reference with options.
This is a convenience wrapper around erlang:demonitor/2.
Erases the entire process dictionary.
This is a convenience wrapper around erlang:erase/0.
Erases the given key from the process dictionary.
This is a convenience wrapper around erlang:erase/1.
-spec exit(process_ref(), term()) -> true.
Terminates the given process with the given reason.
This is a convenience wrapper around erlang:exit/2.
-spec flag(process_flag(), term()) -> term().
Sets a process flag for the current process.
This is a convenience wrapper around erlang:process_flag/2.
Returns the process dictionary of the current process.
This is a convenience wrapper around erlang:get/0.
Returns the value associated with the given key in the process dictionary.
This is a convenience wrapper around erlang:get/1.
-spec get_keys() -> [term()].
Returns all keys in the process dictionary.
This is a convenience wrapper around erlang:get_keys/0.
Returns all keys associated with the given value in the process dictionary.
This is a convenience wrapper around erlang:get_keys/1.
-spec group_leader() -> pid().
Returns the group leader of the current process.
This is a convenience wrapper around erlang:group_leader/0.
-spec group_leader(pid(), process_ref()) -> true.
Sets the group leader of the given process.
This is a convenience wrapper around erlang:group_leader/2.
-spec info() -> [{process_info_item(), term()}].
Returns information about the current process.
This is equivalent to info(self()).
-spec info(process_ref()) -> [{process_info_item(), term()}] | undefined.
Returns information about the given process.
Returns undefined if the process is not alive.
-spec info(process_ref(), process_info_item()) -> {process_info_item(), term()} | undefined.
Returns specific information about the given process.
Returns undefined if the process is not alive or the info item is not available.
-spec monitor(process_ref()) -> reference().
Monitors the given process and returns the monitor reference.
This is a convenience wrapper around erlang:monitor/2.
Stores a key-value pair in the process dictionary.
This is a convenience wrapper around erlang:put/2.
-spec register(atom(), process_ref()) -> true.
Registers the current process under the given name.
This is a convenience wrapper around erlang:register/2.
-spec registered() -> [atom()].
Returns a list of all registered process names.
This is a convenience wrapper around erlang:registered/0.
-spec send_after(non_neg_integer(), process_ref(), term()) -> reference().
Sends a message to a process after the given time.
This is a convenience wrapper around erlang:send_after/3.
-spec send_interval(non_neg_integer(), process_ref(), term()) -> {ok, reference()} | {error, term()}.
Sends a message to a process repeatedly at the given interval.
This is a convenience wrapper around timer:send_interval/3.
-spec sleep(non_neg_integer()) -> ok.
Sleeps the current process for the given number of milliseconds.
This is a convenience wrapper around timer:sleep/1.
-spec unregister(atom()) -> true.
Unregisters the given name.
This is a convenience wrapper around erlang:unregister/1.
Returns the PID of the process registered under the given name.
This is a convenience wrapper around erlang:whereis/1.