diff options
Diffstat (limited to 'lib/dialyzer/test/race_SUITE_data/src')
-rw-r--r-- | lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl b/lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl new file mode 100644 index 0000000000..4caa9fe8a0 --- /dev/null +++ b/lib/dialyzer/test/race_SUITE_data/src/ets_insert_public.erl @@ -0,0 +1,23 @@ +%% This tests the presence of possible races due to an ets:lookup/ets:insert +%% combination. It takes into account any public ETS tables that might exist. + +-module(ets_insert_public). + +-export([main/1]). + +%% Main +main(Foo) -> + make_table(Foo), + ets:insert(Foo, {counter, 0}), + [{_, N}] = ets:lookup(Foo, counter), + NewN = N + 1, + ets:insert(Foo, {counter, NewN}), + NewN. + +make_table(Foo) -> + init(Foo). + +init(Foo) -> + ets:new(Foo, [named_table, public]), + ets:insert(Foo, {counter, 0}), + {ok, feeling_good}. |