Skip to content

Commit

Permalink
fix(stageleft): support tuple patterns (#1445)
Browse files Browse the repository at this point in the history
Fixes #1139
  • Loading branch information
shadaj authored Sep 5, 2024
1 parent 4f3b51b commit 486dfbe
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
7 changes: 3 additions & 4 deletions hydroflow_plus_test/src/cluster/paxos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -912,10 +912,9 @@ fn client<'a>(
)| {
let mut latencies_mut = latencies.borrow_mut();
let median_latency = if has_any_value {
// let (lesser, median, greater) = latencies.borrow_mut().select_nth_unstable(*median_latency_window_size / 2);
// TODO: Replace below with above once HF+ supports tuples
let out = latencies_mut.select_nth_unstable(median_latency_window_size / 2);
*out.1
let (_, median, _) =
latencies_mut.select_nth_unstable(median_latency_window_size / 2);
*median
} else {
0
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ expression: built.ir()
),
},
ForEach {
f: stageleft :: runtime_support :: fn1_type_hint :: < ((() , (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize , bool)) , (u32 , i32)) , () > ({ use crate :: __staged :: cluster :: paxos :: * ; let median_latency_window_size = 1usize ; move | ((_ , (latencies , _write_index , has_any_value)) , (throughput , num_ticks) ,) | { let mut latencies_mut = latencies . borrow_mut () ; let median_latency = if has_any_value { let out = latencies_mut . select_nth_unstable (median_latency_window_size / 2) ; * out . 1 } else { 0 } ; println ! ("Median latency: {}ms" , median_latency as f64 / 1000.0) ; println ! ("Throughput: {} requests/s" , throughput) ; println ! ("Num ticks per second: {}" , num_ticks) ; } }),
f: stageleft :: runtime_support :: fn1_type_hint :: < ((() , (std :: rc :: Rc < core :: cell :: RefCell < std :: vec :: Vec < u128 > > > , usize , bool)) , (u32 , i32)) , () > ({ use crate :: __staged :: cluster :: paxos :: * ; let median_latency_window_size = 1usize ; move | ((_ , (latencies , _write_index , has_any_value)) , (throughput , num_ticks) ,) | { let mut latencies_mut = latencies . borrow_mut () ; let median_latency = if has_any_value { let (_ , median , _) = latencies_mut . select_nth_unstable (median_latency_window_size / 2) ; * median } else { 0 } ; println ! ("Median latency: {}ms" , median_latency as f64 / 1000.0) ; println ! ("Throughput: {} requests/s" , throughput) ; println ! ("Num ticks per second: {}" , num_ticks) ; } }),
input: CrossSingleton(
CrossSingleton(
Tee {
Expand Down
5 changes: 5 additions & 0 deletions stageleft_macro/src/quote_impl/free_variable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ impl<'ast> syn::visit::Visit<'ast> for FreeVariableVisitor {
syn::Pat::Wild(_) => {
// Do nothing
}
syn::Pat::Tuple(pat_tuple) => {
for el in &pat_tuple.elems {
self.visit_pat(el);
}
}
_ => panic!("Local variables must be identifiers, got {:?}", i.pat),
}
}
Expand Down

0 comments on commit 486dfbe

Please sign in to comment.