Skip to content

Commit

Permalink
Minor tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
sgdxbc committed Jul 8, 2024
1 parent 2fe6d71 commit 27a3530
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 13 deletions.
8 changes: 4 additions & 4 deletions examples/unreplicated-check.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ fn main() -> anyhow::Result<()> {

type O = kvstore::Op;
type R = kvstore::Result;
type TypedW<W> = Decode<R, Encode<O, W>>;
type C<W> = ClientLocalContext<TypedW<W>>;
type CodecW<W> = Decode<R, Encode<O, W>>;
type C<W> = ClientLocalContext<CodecW<W>>;

let settings = Settings {
invariant: |_: &_| Ok(()),
Expand Down Expand Up @@ -105,7 +105,7 @@ fn main() -> anyhow::Result<()> {
state.init()?;

fn append_linearizable<W: Workload<Op = O, Result = R>>(
state: &State<TypedW<Record<W, O, R>>>,
state: &State<CodecW<Record<O, R, W>>>,
) -> anyhow::Result<()> {
let mut all_results = Vec::new();
for (_, context) in &state.clients {
Expand Down Expand Up @@ -139,7 +139,7 @@ fn main() -> anyhow::Result<()> {
state
.clients
.iter()
.all(|(_, context): &(_, C<Record<UncheckedIter<_, _>, _, _>>)| {
.all(|(_, context): &(_, C<Record<_, _, UncheckedIter<_, _>>>)| {
context.upcall.workload.done
})
},
Expand Down
18 changes: 9 additions & 9 deletions src/workload/combinators.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ use super::{
};

#[derive(Debug, Clone)]
pub struct Iter<I, R> {
pub struct Iter<R, I> {
generate: I,
expected_result: Option<R>,
pub done: bool,
}

impl<I, R> Iter<I, R> {
impl<R, I> Iter<R, I> {
pub fn new(generate: impl IntoIterator<IntoIter = I>) -> Self {
Self {
generate: generate.into_iter(),
Expand All @@ -26,7 +26,7 @@ impl<I, R> Iter<I, R> {
}
}

impl<I: Iterator> Workload for Iter<I, <I::Item as Pair>::Second>
impl<I: Iterator> Workload for Iter<<I::Item as Pair>::Second, I>
where
I::Item: Pair,
<I::Item as Pair>::Second: Eq,
Expand Down Expand Up @@ -79,13 +79,13 @@ impl<A, B> Pair for (A, B) {
}

#[derive(Debug, Clone)]
pub struct UncheckedIter<I, R> {
pub struct UncheckedIter<R, I> {
generate: I,
pub done: bool,
_m: PhantomData<R>,
}

impl<I, R> UncheckedIter<I, R> {
impl<R, I> UncheckedIter<R, I> {
pub fn new(generate: impl IntoIterator<IntoIter = I>) -> Self {
Self {
generate: generate.into_iter(),
Expand All @@ -95,7 +95,7 @@ impl<I, R> UncheckedIter<I, R> {
}
}

impl<I: Iterator, R> Workload for UncheckedIter<I, R> {
impl<R, I: Iterator> Workload for UncheckedIter<R, I> {
type Op = I::Item;
type Result = R;

Expand All @@ -117,14 +117,14 @@ impl<I: Iterator, R> Workload for UncheckedIter<I, R> {
}

#[derive(Debug, Clone, Deref)]
pub struct Record<W, O, R> {
pub struct Record<O, R, W> {
#[deref]
inner: W,
pub invocations: Vec<(O, R)>,
outstanding: Option<O>,
}

impl<W, O, R> Record<W, O, R> {
impl<O, R, W> Record<O, R, W> {
pub fn new(workload: W) -> Self {
Self {
inner: workload,
Expand All @@ -134,7 +134,7 @@ impl<W, O, R> Record<W, O, R> {
}
}

impl<W: Workload> Workload for Record<W, W::Op, W::Result>
impl<W: Workload> Workload for Record<W::Op, W::Result, W>
where
W::Op: Clone,
W::Result: Clone,
Expand Down

0 comments on commit 27a3530

Please sign in to comment.