aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src
diff options
context:
space:
mode:
authorHenrik Nord <[email protected]>2014-11-20 10:34:30 +0100
committerHenrik Nord <[email protected]>2014-11-20 10:34:30 +0100
commitcb372c96f3449cfca69e2737fa3d4503fa24444a (patch)
treeaebe5eb6b57be4527427d22983ca2e9f3bf6bdf7 /lib/stdlib/src
parent2feb7638d47f2d1012871de3040fa7d50f058e3a (diff)
parent69e8387629bdea141e196c515f4d9381f7ac3e18 (diff)
downloadotp-cb372c96f3449cfca69e2737fa3d4503fa24444a.tar.gz
otp-cb372c96f3449cfca69e2737fa3d4503fa24444a.tar.bz2
otp-cb372c96f3449cfca69e2737fa3d4503fa24444a.zip
Merge branch 'legoscia/io-message-queue-optimisation' into maint
* legoscia/io-message-queue-optimisation: Optimise io requests for long message queues
Diffstat (limited to 'lib/stdlib/src')
-rw-r--r--lib/stdlib/src/io.erl43
1 files changed, 17 insertions, 26 deletions
diff --git a/lib/stdlib/src/io.erl b/lib/stdlib/src/io.erl
index 27e2a82b41..b9ace2f442 100644
--- a/lib/stdlib/src/io.erl
+++ b/lib/stdlib/src/io.erl
@@ -566,12 +566,23 @@ request(Name, Request) when is_atom(Name) ->
execute_request(Pid, {Convert,Converted}) ->
Mref = erlang:monitor(process, Pid),
- Pid ! {io_request,self(),Pid,Converted},
- if
- Convert ->
- convert_binaries(wait_io_mon_reply(Pid, Mref));
- true ->
- wait_io_mon_reply(Pid, Mref)
+ Pid ! {io_request,self(),Mref,Converted},
+
+ receive
+ {io_reply, Mref, Reply} ->
+ erlang:demonitor(Mref, [flush]),
+ if
+ Convert ->
+ convert_binaries(Reply);
+ true ->
+ Reply
+ end;
+ {'DOWN', Mref, _, _, _} ->
+ receive
+ {'EXIT', Pid, _What} -> true
+ after 0 -> true
+ end,
+ {error,terminated}
end.
requests(Requests) -> %Requests as atomic action
@@ -597,26 +608,6 @@ default_input() ->
default_output() ->
group_leader().
-wait_io_mon_reply(From, Mref) ->
- receive
- {io_reply, From, Reply} ->
- erlang:demonitor(Mref, [flush]),
- Reply;
- {'EXIT', From, _What} ->
- receive
- {'DOWN', Mref, _, _, _} -> true
- after 0 -> true
- end,
- {error,terminated};
- {'DOWN', Mref, _, _, _} ->
- receive
- {'EXIT', From, _What} -> true
- after 0 -> true
- end,
- {error,terminated}
- end.
-
-
%% io_requests(Requests)
%% Transform requests into correct i/o server messages. Only handle the
%% one we KNOW must be changed, others, including incorrect ones, are