11defmodule Process do
22 @ moduledoc """
3- This module provides convenience functions around processes and
4- the process dictionary. In Erlang, most of these functions are
5- auto-imported, but in Elixir they are grouped in a module for
6- convenience. Notice that these functions, different from Erlang's,
7- always return nil instead of undefined. You can use their Erlang
8- version if you want the undefined value.
3+ Conveniences for working with processes and the process dictionary.
4+
5+ Some of the functions in this module are inlined by the compiler,
6+ similar to functions in the `Kernel` module. When such happens,
7+ they are explicitly tagged as so.
98 """
109
1110 @ doc """
@@ -81,16 +80,18 @@ defmodule Process do
8180 1) If pid is not trapping exits, pid will exit with the given reason;
8281
8382 2) If pid is trapping exits, the exit signal is transformed into a message
84- {' EXIT' , from, reason} and delivered to the message queue of pid;
83+ {: EXIT, from, reason} and delivered to the message queue of pid;
8584
8685 3) If reason is the atom `:normal`, pid will not exit. If it is trapping exits,
87- the exit signal is transformed into a message {' EXIT' , from, :normal} and
86+ the exit signal is transformed into a message {: EXIT, from, :normal} and
8887 delivered to its message queue;
8988
9089 4) If reason is the atom `:kill`, that is if `exit(pid, :kill)` is called, an
9190 untrappable exit signal is sent to pid which will unconditionally exit with
9291 exit reason `:killed`.
9392
93+ Inlined by the compiler.
94+
9495 ## Examples
9596
9697 Process.exit(pid, :kill)
@@ -112,6 +113,8 @@ defmodule Process do
112113 @ doc """
113114 Returns the pid of a new process started by the application of `fun`.
114115 It behaves exactly the same as `Kernel.spawn/1`.
116+
117+ Inlined by the compiler.
115118 """
116119 @ spec spawn ( ( ( ) -> any ) ) :: pid
117120 def spawn ( fun ) do
@@ -129,6 +132,8 @@ defmodule Process do
129132
130133 It also accepts extra options, for the list of available options
131134 check http://www.erlang.org/doc/man/erlang.html#spawn_opt-2
135+
136+ Inlined by the compiler.
132137 """
133138 @ spec spawn ( ( ( ) -> any ) , spawn_opts ) :: pid | { pid , reference }
134139 def spawn ( fun , opts ) do
@@ -141,6 +146,8 @@ defmodule Process do
141146 scheduler queue and be run some time later.
142147
143148 It behaves exactly the same as the `Kernel.spawn/3` function.
149+
150+ Inlined by the compiler.
144151 """
145152 @ spec spawn ( module , atom , [ any ] ) :: pid
146153 def spawn ( mod , fun , args ) do
@@ -155,6 +162,7 @@ defmodule Process do
155162 It also accepts extra options, for the list of available options
156163 check http://www.erlang.org/doc/man/erlang.html#spawn_opt-4
157164
165+ Inlined by the compiler.
158166 """
159167 @ spec spawn ( module , atom , [ any ] , spawn_opts ) :: pid | { pid , reference }
160168 def spawn ( mod , fun , args , opts ) do
@@ -165,6 +173,8 @@ defmodule Process do
165173 Returns the pid of a new process started by the application of `fun`.
166174 A link is created between the calling process and the new
167175 process, atomically.
176+
177+ Inlined by the compiler.
168178 """
169179 @ spec spawn_link ( ( ( ) -> any ) ) :: pid
170180 def spawn_link ( fun ) do
@@ -175,6 +185,8 @@ defmodule Process do
175185 Returns the pid of a new process started by the application of
176186 `module.function(args)`. A link is created between the calling process
177187 and the new process, atomically. Otherwise works like spawn/3.
188+
189+ Inlined by the compiler.
178190 """
179191 @ spec spawn_link ( module , atom , [ any ] ) :: pid
180192 def spawn_link ( mod , fun , args ) do
@@ -184,6 +196,8 @@ defmodule Process do
184196 @ doc """
185197 Returns the pid of a new process started by the application of `fun`
186198 and reference for a monitor created to the new process.
199+
200+ Inlined by the compiler.
187201 """
188202 @ spec spawn_monitor ( ( ( ) -> any ) ) :: { pid , reference }
189203 def spawn_monitor ( fun ) do
@@ -194,6 +208,8 @@ defmodule Process do
194208 A new process is started by the application of `module.function(args)`
195209 and the process is monitored at the same time. Returns the pid and a
196210 reference for the monitor. Otherwise works like spawn/3.
211+
212+ Inlined by the compiler.
197213 """
198214 @ spec spawn_monitor ( module , atom , [ any ] ) :: { pid , reference }
199215 def spawn_monitor ( mod , fun , args ) do
@@ -205,6 +221,8 @@ defmodule Process do
205221 It returns the monitor reference.
206222
207223 See http://www.erlang.org/doc/man/erlang.html#monitor-2 for more info.
224+
225+ Inlined by the compiler.
208226 """
209227 @ spec monitor ( pid | { reg_name :: atom , node :: atom } | reg_name :: atom ) :: reference
210228 def monitor ( item ) do
@@ -217,6 +235,8 @@ defmodule Process do
217235 If the monitoring is already turned off, nothing happens.
218236
219237 See http://www.erlang.org/doc/man/erlang.html#demonitor-2 for more info.
238+
239+ Inlined by the compiler.
220240 """
221241 @ spec demonitor ( reference ) :: true
222242 @ spec demonitor ( reference , options :: [ :flush | :info ] ) :: boolean
@@ -244,6 +264,8 @@ defmodule Process do
244264 (or port) `pid`, if there is not such a link already.
245265
246266 See http://www.erlang.org/doc/man/erlang.html#link-1 for more info.
267+
268+ Inlined by the compiler.
247269 """
248270 @ spec link ( pid | port ) :: true
249271 def link ( pid ) do
@@ -256,6 +278,8 @@ defmodule Process do
256278 fail, even if there is no link or `id` does not exist
257279
258280 See http://www.erlang.org/doc/man/erlang.html#unlink-1 for more info.
281+
282+ Inlined by the compiler.
259283 """
260284 @ spec unlink ( pid | port ) :: true
261285 def unlink ( pid ) do
0 commit comments