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:
parent
6f6d9f74bc
commit
0236c64ace
|
|
@ -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},
|
||||
|
|
|
|||
Loading…
Reference in New Issue