Skip to content

Commit

Permalink
Factor out binheap/round_robin.py state updates
Browse files Browse the repository at this point in the history
  • Loading branch information
polybeandip committed Sep 24, 2024
1 parent d4163d8 commit 5406ab6
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions frontends/queues/queues/binheap/round_robin.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,19 @@ def binheap_invoke(value, rank):
for i in range(n)
])

update_state_pop = [
infer_flow_out,
cb.while_with(
turn_neq_flow_out,
[
comp.case(turn.out, rank_ptr_incrs),
turn_incr_mod_n
]
),
turn_incr_mod_n
]
update_state_push = comp.case(flow_in.out, rank_ptr_incrs)

comp.control += [
init_state,
infer_flow_in,
Expand All @@ -76,22 +89,7 @@ def binheap_invoke(value, rank):
err_eq_0,
comp.case(
cmd,
{
0:
[
infer_flow_out,
cb.while_with(
turn_neq_flow_out,
[
comp.case(turn.out, rank_ptr_incrs),
turn_incr_mod_n
]
),
turn_incr_mod_n
],
1:
comp.case(flow_in.out, rank_ptr_incrs)
}
{ 0: update_state_pop, 1: update_state_push }
)
)
]
Expand Down

0 comments on commit 5406ab6

Please sign in to comment.