Reduce chances of variable capture in ?awaitMatch

Attempt to name all of the variables in the macro such that they are less
likely to collide with any existing bindings.
This commit is contained in:
Philip Kuryloski 2020-07-06 12:08:23 +02:00
parent 6f6d9f74bc
commit 0236c64ace
1 changed files with 7 additions and 7 deletions

View File

@ -1,13 +1,13 @@
-define(awaitMatch(Guard, Expr, Timeout),
begin
((fun Filter(Horizon) ->
R = Expr,
case (R) of
Guard -> R;
((fun AwaitMatchFilter(AwaitMatchHorizon) ->
AwaitMatchResult = Expr,
case (AwaitMatchResult) of
Guard -> AwaitMatchResult;
__V -> case erlang:system_time(millisecond) of
Now when Now < Horizon ->
timer:sleep(min(50, Horizon - Now)),
Filter(Horizon);
AwaitMatchNow when AwaitMatchNow < AwaitMatchHorizon ->
timer:sleep(min(50, AwaitMatchHorizon - AwaitMatchNow)),
AwaitMatchFilter(AwaitMatchHorizon);
_ ->
erlang:error({awaitMatch,
[{module, ?MODULE},