aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/gen_event.erl
diff options
context:
space:
mode:
authorFredrik Gustafsson <[email protected]>2013-04-04 14:38:00 +0200
committerFredrik Gustafsson <[email protected]>2013-04-04 14:38:00 +0200
commite72043e3519cb14aabf461849eba959b97e07410 (patch)
tree4dd3d5fc301fef9acc620ba73205ea9fb7881acc /lib/stdlib/src/gen_event.erl
parentbad78f7daf7299603ea807c90839450a5f1307ce (diff)
parent709823671313793a6e29abfde4cbb548348910c2 (diff)
downloadotp-e72043e3519cb14aabf461849eba959b97e07410.tar.gz
otp-e72043e3519cb14aabf461849eba959b97e07410.tar.bz2
otp-e72043e3519cb14aabf461849eba959b97e07410.zip
Merge branch 'sv/stdlib/sys-get-state/OTP-11013' into maint
* sv/stdlib/sys-get-state/OTP-11013: Removed ?line macro add sys:get_state/1,2 and sys:replace_state/2,3 update sys:get_status/2,3 documentation for gen_event
Diffstat (limited to 'lib/stdlib/src/gen_event.erl')
-rw-r--r--lib/stdlib/src/gen_event.erl18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/stdlib/src/gen_event.erl b/lib/stdlib/src/gen_event.erl
index 2b8ba86909..bfebf29080 100644
--- a/lib/stdlib/src/gen_event.erl
+++ b/lib/stdlib/src/gen_event.erl
@@ -229,6 +229,24 @@ wake_hib(Parent, ServerName, MSL, Debug) ->
fetch_msg(Parent, ServerName, MSL, Debug, Hib) ->
receive
+ {system, From, get_state} ->
+ States = [{Mod,Id,State} || #handler{module=Mod, id=Id, state=State} <- MSL],
+ sys:handle_system_msg(get_state, From, Parent, ?MODULE, Debug,
+ {States, [ServerName, MSL, Hib]}, Hib);
+ {system, From, {replace_state, StateFun}} ->
+ {NMSL, NStates} =
+ lists:unzip([begin
+ Cur = {Mod,Id,State},
+ try
+ NState = {Mod,Id,NS} = StateFun(Cur),
+ {HS#handler{state=NS}, NState}
+ catch
+ _:_ ->
+ {HS, Cur}
+ end
+ end || #handler{module=Mod, id=Id, state=State}=HS <- MSL]),
+ sys:handle_system_msg(replace_state, From, Parent, ?MODULE, Debug,
+ {NStates, [ServerName, NMSL, Hib]}, Hib);
{system, From, Req} ->
sys:handle_system_msg(Req, From, Parent, ?MODULE, Debug,
[ServerName, MSL, Hib],Hib);