-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: replace IoId with CallId (#2150)
Co-authored-by: Tushar Mathur <[email protected]>
- Loading branch information
1 parent
47dfcad
commit 598b3f9
Showing
16 changed files
with
145 additions
and
66 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,38 @@ | ||
use std::cell::Cell; | ||
use std::sync::Mutex; | ||
|
||
pub trait Count { | ||
type Item; | ||
fn next(&self) -> Self::Item; | ||
} | ||
|
||
#[allow(unused)] | ||
#[derive(Default)] | ||
pub struct Counter(Cell<usize>); | ||
impl Counter { | ||
pub fn new(start: usize) -> Self { | ||
pub struct Counter<A>(Cell<A>); | ||
impl<A> Counter<A> { | ||
pub fn new(start: A) -> Self { | ||
Self(Cell::new(start)) | ||
} | ||
pub fn next(&self) -> usize { | ||
} | ||
|
||
impl<A: Copy + num::Num> Count for Counter<A> { | ||
type Item = A; | ||
|
||
fn next(&self) -> A { | ||
let curr = self.0.get(); | ||
self.0.set(curr + 1); | ||
self.0.set(curr + A::one()); | ||
curr | ||
} | ||
} | ||
|
||
#[derive(Default)] | ||
pub struct AtomicCounter<A>(Mutex<A>); | ||
|
||
impl<A: Copy + num::Num> Count for AtomicCounter<A> { | ||
type Item = A; | ||
|
||
fn next(&self) -> A { | ||
let mut x = self.0.lock().unwrap(); | ||
*x = *x + A::one(); | ||
*x | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.