Skip to content
This repository has been archived by the owner on Sep 28, 2021. It is now read-only.

Commit

Permalink
Support multiple wait_needed's per variable.
Browse files Browse the repository at this point in the history
Support multiple calls of wait_needed per dataflow variable.
  • Loading branch information
cmeiklejohn committed Dec 18, 2014
1 parent 8a14810 commit 656a974
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
2 changes: 1 addition & 1 deletion include/derflow.hrl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
next,
waiting_threads = [],
binding_list = [],
creator,
lazy_threads = [],
type,
lazy = false,
bound = false}).
Expand Down
9 changes: 6 additions & 3 deletions src/derflow_ets.erl
Original file line number Diff line number Diff line change
Expand Up @@ -367,8 +367,8 @@ next(Id, Store, DeclareNextFun) ->
read(Id, Threshold, Store, Self, ReplyFun, BlockingFun) ->
[{_Key, V=#dv{value=Value,
bound=Bound,
creator=Creator,
lazy=Lazy,
lazy_threads=LazyThreads,
type=Type}}] = ets:lookup(Store, Id),
case Bound of
true ->
Expand Down Expand Up @@ -410,7 +410,7 @@ read(Id, Threshold, Store, Self, ReplyFun, BlockingFun) ->
true = ets:insert(Store, {Id, V#dv{waiting_threads=WT}}),
case Lazy of
true ->
{ok, _} = reply_to_all([Creator], ok),
{ok, _} = reply_to_all(LazyThreads, ok),
BlockingFun();
false ->
BlockingFun()
Expand Down Expand Up @@ -523,6 +523,7 @@ select(Id, Function, AccId, Store, BindFun) ->
wait_needed(Id, Store, Self, ReplyFun, BlockingFun) ->
lager:info("Wait needed issued for identifier: ~p", [Id]),
[{_Key, V=#dv{waiting_threads=WT,
lazy_threads=LazyThreads0,
bound=Bound}}] = ets:lookup(Store, Id),
case Bound of
true ->
Expand All @@ -532,8 +533,10 @@ wait_needed(Id, Store, Self, ReplyFun, BlockingFun) ->
[_H|_T] ->
ReplyFun();
_ ->
LazyThreads = lists:append(LazyThreads0, [Self]),
true = ets:insert(Store,
{Id, V#dv{lazy=true, creator=Self}}),
{Id, V#dv{lazy=true,
lazy_threads=LazyThreads}}),
BlockingFun()
end
end.
Expand Down

0 comments on commit 656a974

Please sign in to comment.