Skip to content

Commit e1ed3d6

Browse files
authored
Merge pull request #1088 from JPDye/update-to-atomicU64
switch AtomicUsize to AtomicU64 in example now that it's stable
2 parents 8314870 + 354944c commit e1ed3d6

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

examples/loopback.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -42,21 +42,19 @@ mod mock {
4242
mod mock {
4343
use smoltcp::time::{Duration, Instant};
4444
use std::sync::Arc;
45-
use std::sync::atomic::{AtomicUsize, Ordering};
45+
use std::sync::atomic::{AtomicU64, Ordering};
4646

47-
// should be AtomicU64 but that's unstable
4847
#[derive(Debug, Clone)]
4948
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
50-
pub struct Clock(Arc<AtomicUsize>);
49+
pub struct Clock(Arc<AtomicU64>);
5150

5251
impl Clock {
5352
pub fn new() -> Clock {
54-
Clock(Arc::new(AtomicUsize::new(0)))
53+
Clock(Arc::new(AtomicU64::new(0)))
5554
}
5655

5756
pub fn advance(&self, duration: Duration) {
58-
self.0
59-
.fetch_add(duration.total_millis() as usize, Ordering::SeqCst);
57+
self.0.fetch_add(duration.total_millis(), Ordering::SeqCst);
6058
}
6159

6260
pub fn elapsed(&self) -> Instant {

fuzz/fuzz_targets/tcp_headers.rs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,20 @@ mod utils;
1313

1414
mod mock {
1515
use smoltcp::time::{Duration, Instant};
16-
use std::sync::atomic::{AtomicUsize, Ordering};
1716
use std::sync::Arc;
17+
use std::sync::atomic::{AtomicU64, Ordering};
1818

19-
// should be AtomicU64 but that's unstable
2019
#[derive(Debug, Clone)]
2120
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
22-
pub struct Clock(Arc<AtomicUsize>);
21+
pub struct Clock(Arc<AtomicU64>);
2322

2423
impl Clock {
2524
pub fn new() -> Clock {
26-
Clock(Arc::new(AtomicUsize::new(0)))
25+
Clock(Arc::new(AtomicU64::new(0)))
2726
}
2827

2928
pub fn advance(&self, duration: Duration) {
30-
self.0
31-
.fetch_add(duration.total_millis() as usize, Ordering::SeqCst);
29+
self.0.fetch_add(duration.total_millis(), Ordering::SeqCst);
3230
}
3331

3432
pub fn elapsed(&self) -> Instant {

0 commit comments

Comments
 (0)