aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/gen.erl
diff options
context:
space:
mode:
authorBjörn Gustavsson <[email protected]>2010-04-22 09:15:45 +0200
committerBjörn Gustavsson <[email protected]>2010-05-10 07:16:04 +0200
commit23362aeb8f364adb64a0825ea40dcb1158babe13 (patch)
tree095a2d6402c4bde4ede41d1afec3a33d49f0eb8d /lib/stdlib/src/gen.erl
parent9a47f399acb54eac86b79b274aaf4f191a765961 (diff)
downloadotp-23362aeb8f364adb64a0825ea40dcb1158babe13.tar.gz
otp-23362aeb8f364adb64a0825ea40dcb1158babe13.tar.bz2
otp-23362aeb8f364adb64a0825ea40dcb1158babe13.zip
gen: Inline wait_resp_mon/2 to help the compiler optimize
We are about to introduce a new optimization that requires the creation of a monitor and the following receive statement to be in the same function.
Diffstat (limited to 'lib/stdlib/src/gen.erl')
-rw-r--r--lib/stdlib/src/gen.erl35
1 files changed, 16 insertions, 19 deletions
diff --git a/lib/stdlib/src/gen.erl b/lib/stdlib/src/gen.erl
index 5aab547644..30f48d39b7 100644
--- a/lib/stdlib/src/gen.erl
+++ b/lib/stdlib/src/gen.erl
@@ -212,7 +212,22 @@ do_call(Process, Label, Request, Timeout) ->
catch erlang:send(Process, {Label, {self(), Mref}, Request},
[noconnect]),
- wait_resp_mon(Node, Mref, Timeout)
+ receive
+ {Mref, Reply} ->
+ erlang:demonitor(Mref, [flush]),
+ {ok, Reply};
+ {'DOWN', Mref, _, _, noconnection} ->
+ exit({nodedown, Node});
+ {'DOWN', Mref, _, _, Reason} ->
+ exit(Reason)
+ after Timeout ->
+ erlang:demonitor(Mref),
+ receive
+ {'DOWN', Mref, _, _, _} -> true
+ after 0 -> true
+ end,
+ exit(timeout)
+ end
catch
error:_ ->
%% Node (C/Java?) is not supporting the monitor.
@@ -233,24 +248,6 @@ do_call(Process, Label, Request, Timeout) ->
end
end.
-wait_resp_mon(Node, Mref, Timeout) ->
- receive
- {Mref, Reply} ->
- erlang:demonitor(Mref, [flush]),
- {ok, Reply};
- {'DOWN', Mref, _, _, noconnection} ->
- exit({nodedown, Node});
- {'DOWN', Mref, _, _, Reason} ->
- exit(Reason)
- after Timeout ->
- erlang:demonitor(Mref),
- receive
- {'DOWN', Mref, _, _, _} -> true
- after 0 -> true
- end,
- exit(timeout)
- end.
-
wait_resp(Node, Tag, Timeout) ->
receive
{Tag, Reply} ->