Skip to content

Commit

Permalink
Re-run cargo fmt and fix lib::test_components test
Browse files Browse the repository at this point in the history
  • Loading branch information
Qqwy committed Feb 24, 2024
1 parent d1ffe60 commit f61231b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ mod tests {
#[test]
fn test_components() {
let mut components = Components::new(0);
assert_eq!(components.sequence(), 0);
assert_eq!(components.sequence(), 1);
assert_eq!(components.timestamp(), 0);

components.set_sequence(1024);
Expand Down
24 changes: 13 additions & 11 deletions src/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,10 @@ where
F: Fn(),
{
loop {
println!("Waiting until the next millisecond from {}", last_millisecond);
println!(
"Waiting until the next millisecond from {}",
last_millisecond
);
let now = epoch.elapsed().as_millis() as u64;
if now > last_millisecond {
return now;
Expand Down Expand Up @@ -430,18 +433,17 @@ mod loom_tests {
let generator = Arc::new(InternalGenerator::<TestTime>::new_unchecked(0));
let (tx, rx) = mpsc::channel();

let threads: Vec<_> =
(0..THREADS)
.map(|_| {
let generator = generator.clone();
let tx = tx.clone();
let threads: Vec<_> = (0..THREADS)
.map(|_| {
let generator = generator.clone();
let tx = tx.clone();

thread::spawn(move || {
let id: u64 = generator.generate(panic_on_wait);
tx.send(id).unwrap();
})
thread::spawn(move || {
let id: u64 = generator.generate(panic_on_wait);
tx.send(id).unwrap();
})
.collect();
})
.collect();

for th in threads {
th.join().unwrap();
Expand Down

0 comments on commit f61231b

Please sign in to comment.