Skip to content

Commit

Permalink
[ISSUE #357]⚡️Replace Arc<parking_lot::Mutex<u64>> with AtomicU64 of …
Browse files Browse the repository at this point in the history
…MappedFileQueue property (#358)
  • Loading branch information
mxsm authored May 14, 2024
1 parent 7e940b8 commit dc4311f
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions rocketmq-store/src/consume_queue/mapped_file_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
use std::{
fs,
path::{Path, PathBuf},
sync::Arc,
sync::{
atomic::{AtomicU64, Ordering},
Arc,
},
};

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

pub(crate) flushed_where: Arc<parking_lot::Mutex<u64>>,
pub(crate) flushed_where: Arc<AtomicU64>,

pub(crate) committed_where: Arc<parking_lot::Mutex<u64>>,
pub(crate) committed_where: Arc<AtomicU64>,

pub(crate) store_timestamp: Arc<parking_lot::Mutex<u64>>,
pub(crate) store_timestamp: Arc<AtomicU64>,
}

/*impl Swappable for MappedFileQueue {
Expand Down Expand Up @@ -75,9 +78,9 @@ impl MappedFileQueue {
mapped_file_size,
mapped_files: Vec::new(),
allocate_mapped_file_service,
flushed_where: Arc::new(parking_lot::Mutex::new(0)),
committed_where: Arc::new(parking_lot::Mutex::new(0)),
store_timestamp: Arc::new(parking_lot::Mutex::new(0)),
flushed_where: Arc::new(AtomicU64::new(0)),
committed_where: Arc::new(AtomicU64::new(0)),
store_timestamp: Arc::new(AtomicU64::new(0)),
}
}

Expand Down Expand Up @@ -225,11 +228,13 @@ impl MappedFileQueue {
}

pub fn set_flushed_where(&mut self, flushed_where: i64) {
*self.flushed_where.lock() = flushed_where as u64;
self.flushed_where
.store(flushed_where as u64, Ordering::SeqCst);
}

pub fn set_committed_where(&mut self, committed_where: i64) {
*self.committed_where.lock() = committed_where as u64;
self.committed_where
.store(committed_where as u64, Ordering::SeqCst);
}

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

0 comments on commit dc4311f

Please sign in to comment.