diff options
author | Rickard Green <[email protected]> | 2010-12-15 00:56:56 +0100 |
---|---|---|
committer | Rickard Green <[email protected]> | 2010-12-16 12:12:25 +0100 |
commit | 8b18824e2b13e60fb1a067f80dbb228172f6a3d2 (patch) | |
tree | 1a1a5bd6f105eeee03cf38a35d2b9a24c7f20ba8 /lib/stdlib/test | |
parent | 766c7cabb1545418bf59e8dcfcc1a5fae8b01d40 (diff) | |
download | otp-8b18824e2b13e60fb1a067f80dbb228172f6a3d2.tar.gz otp-8b18824e2b13e60fb1a067f80dbb228172f6a3d2.tar.bz2 otp-8b18824e2b13e60fb1a067f80dbb228172f6a3d2.zip |
Safe deallocation of ETS-table structures
Ensure that all threads potentially accessing an ETS-table have dropped
all references to the table before deallocating it.
Diffstat (limited to 'lib/stdlib/test')
-rw-r--r-- | lib/stdlib/test/ets_SUITE.erl | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/stdlib/test/ets_SUITE.erl b/lib/stdlib/test/ets_SUITE.erl index 620848003c..4e789790f6 100644 --- a/lib/stdlib/test/ets_SUITE.erl +++ b/lib/stdlib/test/ets_SUITE.erl @@ -5325,7 +5325,25 @@ my_tab_to_list(_Ts,'$end_of_table', Acc) -> lists:reverse(Acc); my_tab_to_list(Ts,Key, Acc) -> my_tab_to_list(Ts,ets:next(Ts,Key),[ets:lookup(Ts, Key)| Acc]). +wait_for_all_schedulers_online_to_execute() -> + PMs = lists:map(fun (Sched) -> + spawn_opt(fun () -> ok end, + [monitor, {scheduler, Sched}]) + end, + lists:seq(1,erlang:system_info(schedulers_online))), + lists:foreach(fun ({P, M}) -> + receive + {'DOWN', M, process, P, _} -> ok + end + end, + PMs), + ok. + etsmem() -> + %% Wait until it is guaranteed that all already scheduled + %% deallocations of DbTable structures have completed. + wait_for_all_schedulers_online_to_execute(), + AllTabs = lists:map(fun(T) -> {T,ets:info(T,name),ets:info(T,size), ets:info(T,memory),ets:info(T,type)} end, ets:all()), |