Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hydro_optimize_examples/src/compare_and_swap/cas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pub struct CAS<'a, 'b> {

impl<'a, 'b, State, Sender> CASLike<'a, State, Sender> for CAS<'a, 'b>
where
State: Clone + Serialize + for<'de> Deserialize<'de> + Ord + 'a,
State: Clone + Serialize + for<'de> Deserialize<'de> + PartialOrd + 'a,
Sender: Clone + Serialize + for<'de> Deserialize<'de> + Eq + Hash + 'a,
{
fn build(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ impl<'a, 'b> DistributedCAS<'a, 'b> {
/// 2. Each client subscribes at most once. (Doesn't break correctness but will duplicate messages).
impl<'a, 'b, State, Sender> CASLike<'a, State, Sender> for DistributedCAS<'a, 'b>
where
State: Clone + Debug + Serialize + for<'de> Deserialize<'de> + Ord + 'a,
State: Clone + Debug + Serialize + for<'de> Deserialize<'de> + PartialOrd + Eq + 'a,
Sender: Clone + Debug + Serialize + for<'de> Deserialize<'de> + Eq + Hash + 'a,
{
fn build(
Expand Down Expand Up @@ -380,7 +380,12 @@ where
.clone()
.map(q!(|(response, _all_agree)| (response.max_ballot, response.state)))
.chain(committed_state.into_stream())
.max();
.reduce(q!(|(ballot, state), (new_ballot, new_state)| {
if new_ballot >= *ballot {
*ballot = new_ballot;
*state = new_state;
}
}, commutative = manual_proof!(/** Max is commutative. If the new ballot is the same, then state can be overwritten based on order and that's ok. */)));
// Propose a valid client write if the election is succesful and all agree
let proposed_client_write = write_queue
.clone()
Expand Down
8 changes: 0 additions & 8 deletions hydro_optimize_examples/src/compare_and_swap/cas_like.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ impl<S: PartialOrd> PartialOrd for CASState<S> {
}
}

impl<S: Ord> Ord for CASState<S> {
fn cmp(&self, other: &Self) -> std::cmp::Ordering {
self.version
.cmp(&other.version)
.then_with(|| self.state.cmp(&other.state))
}
}

#[derive(Copy, Clone, Debug, Serialize, Deserialize, PartialEq, Eq, Hash)]
pub struct UniqueRequestId {
pub id: u64,
Expand Down
Loading