Skip to content

Commit

Permalink
With the trans tests, don't remove the found IDs, just push them to t…
Browse files Browse the repository at this point in the history
…he back of the queue
  • Loading branch information
choptastic committed Sep 8, 2023
1 parent 0caf688 commit 1099182
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/sql_bridge_test.erl
Original file line number Diff line number Diff line change
Expand Up @@ -112,10 +112,16 @@ lookup_loop(Fruitids) ->
{register, Fruitid} ->
lookup_loop(Fruitids ++ [Fruitid]);
{lookup, Pid} ->
%% Get the first fruit from thee list
[Fruitid|Rest] = Fruitids,
%% send it back to the user
Pid ! Fruitid,
lookup_loop(Rest)
%% Put the found fruitid to the end of the list (so we don't grab it again right away)
NewFruitids = Rest ++ [Fruitid],
%% then loop again
lookup_loop(NewFruitids)
after
%% if no messages received for 10 seconds, we can safely die1
10000 -> die
end.

Expand All @@ -126,7 +132,7 @@ lookup_fruitid(LookupPid, NotFruitid) ->
LookupPid ! {lookup, self()},
receive
NotFruitid ->
register_fruitid(LookupPid, NotFruitid),
%% We happened to retrieve ourselves. We don't want that. Try again (the queue will change with each request)
lookup_fruitid(LookupPid, NotFruitid);
Fruitid ->
Fruitid
Expand Down

0 comments on commit 1099182

Please sign in to comment.