-module(distribute@monitor). -compile([no_auto_import, nowarn_unused_vars, nowarn_unused_function, nowarn_nomatch, inline]). -define(FILEPATH, "src/distribute/monitor.gleam"). -export([self/0, monitor/1, demonitor/1, monitor_node/2]). -export_type([pid_/0, reference_/0, atom_/0]). -if(?OTP_RELEASE >= 27). -define(MODULEDOC(Str), -moduledoc(Str)). -define(DOC(Str), -doc(Str)). -else. -define(MODULEDOC(Str), -compile([])). -define(DOC(Str), -compile([])). -endif. -type pid_() :: any(). -type reference_() :: any(). -type atom_() :: any(). -file("src/distribute/monitor.gleam", 37). ?DOC(" Get the Pid of the current process.\n"). -spec self() -> pid_(). self() -> erlang:self(). -file("src/distribute/monitor.gleam", 44). ?DOC( " Monitor a process. Returns a monitor reference.\n" " When the monitored process terminates, a message of the form\n" " {'DOWN', Reference, process, Pid, Reason} is sent to the caller.\n" ). -spec monitor(pid_()) -> reference_(). monitor(Pid) -> erlang:monitor(monitor_ffi:to_atom(<<"process"/utf8>>), Pid). -file("src/distribute/monitor.gleam", 50). ?DOC( " Stop monitoring a process.\n" " Returns True if the monitor was found and removed.\n" ). -spec demonitor(reference_()) -> boolean(). demonitor(Ref) -> erlang:demonitor(Ref). -file("src/distribute/monitor.gleam", 58). ?DOC( " Monitor a node for up/down events.\n" " Pass True to start monitoring, False to stop.\n" " Note: This function requires the current node to be distributed,\n" " otherwise it will raise a 'notalive' error.\n" ). -spec monitor_node(binary(), boolean()) -> boolean(). monitor_node(Node, Flag) -> erlang:monitor_node(monitor_ffi:to_atom(Node), Flag).