Skip to content

Commit dc4311f

Browse files
authored
[ISSUE #357]⚡️Replace Arc<parking_lot::Mutex<u64>> with AtomicU64 of MappedFileQueue property (#358)
1 parent 7e940b8 commit dc4311f

File tree

1 file changed

+14
-9
lines changed

1 file changed

+14
-9
lines changed

rocketmq-store/src/consume_queue/mapped_file_queue.rs

+14-9
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
use std::{
1919
fs,
2020
path::{Path, PathBuf},
21-
sync::Arc,
21+
sync::{
22+
atomic::{AtomicU64, Ordering},
23+
Arc,
24+
},
2225
};
2326

2427
use log::warn;
@@ -42,11 +45,11 @@ pub struct MappedFileQueue {
4245
// pub(crate) mapped_files: Vec<LocalMappedFile>,
4346
pub(crate) allocate_mapped_file_service: Option<AllocateMappedFileService>,
4447

45-
pub(crate) flushed_where: Arc<parking_lot::Mutex<u64>>,
48+
pub(crate) flushed_where: Arc<AtomicU64>,
4649

47-
pub(crate) committed_where: Arc<parking_lot::Mutex<u64>>,
50+
pub(crate) committed_where: Arc<AtomicU64>,
4851

49-
pub(crate) store_timestamp: Arc<parking_lot::Mutex<u64>>,
52+
pub(crate) store_timestamp: Arc<AtomicU64>,
5053
}
5154

5255
/*impl Swappable for MappedFileQueue {
@@ -75,9 +78,9 @@ impl MappedFileQueue {
7578
mapped_file_size,
7679
mapped_files: Vec::new(),
7780
allocate_mapped_file_service,
78-
flushed_where: Arc::new(parking_lot::Mutex::new(0)),
79-
committed_where: Arc::new(parking_lot::Mutex::new(0)),
80-
store_timestamp: Arc::new(parking_lot::Mutex::new(0)),
81+
flushed_where: Arc::new(AtomicU64::new(0)),
82+
committed_where: Arc::new(AtomicU64::new(0)),
83+
store_timestamp: Arc::new(AtomicU64::new(0)),
8184
}
8285
}
8386

@@ -225,11 +228,13 @@ impl MappedFileQueue {
225228
}
226229

227230
pub fn set_flushed_where(&mut self, flushed_where: i64) {
228-
*self.flushed_where.lock() = flushed_where as u64;
231+
self.flushed_where
232+
.store(flushed_where as u64, Ordering::SeqCst);
229233
}
230234

231235
pub fn set_committed_where(&mut self, committed_where: i64) {
232-
*self.committed_where.lock() = committed_where as u64;
236+
self.committed_where
237+
.store(committed_where as u64, Ordering::SeqCst);
233238
}
234239

235240
pub fn truncate_dirty_files(&mut self, offset: i64) {}

0 commit comments

Comments
 (0)