1
%% This tests the presence of possible races due to an ets:lookup/ets:insert
2
%% combination. It takes into account control flow that might exist.
4
-module(ets_insert_control_flow1).
8
io:format("Created ~w\n", [ets:new(foo, [named_table, public])]),
9
ets:insert(foo, {random, random:uniform(maria:get_int())}),
10
io:format("Inserted ~w\n", [{_, N}] = ets:lookup(foo, random)),
11
case (N rem 2 == 0) of
13
io:format("\nInserted an even number\n", []),
14
io:format("\nWill make it odd\n", []),
15
ets:insert(foo, {random, N+1});
18
io:format("Update complete\n", []),
19
ObjectList = ets:lookup(foo, random),
20
io:format("Random odd integer: ~w\n", [ObjectList]).