-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
no need to explicitly store ChunkDescriptor in BusyChunk as now it is…
… stored in shared metadata
- Loading branch information
1 parent
f2df6e8
commit 25f7b05
Showing
3 changed files
with
55 additions
and
37 deletions.
There are no files selected for viewing
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 |
---|---|---|
|
@@ -12,7 +12,12 @@ | |
// ZettaScale Zenoh Team, <[email protected]> | ||
// | ||
|
||
use std::sync::atomic::{AtomicBool, AtomicU32, AtomicUsize}; | ||
use std::{ | ||
num::NonZeroUsize, | ||
sync::atomic::{AtomicBool, AtomicU32, AtomicUsize, Ordering}, | ||
}; | ||
|
||
use crate::api::provider::chunk::ChunkDescriptor; | ||
|
||
// Chunk header | ||
#[stabby::stabby] | ||
|
@@ -30,7 +35,24 @@ pub struct ChunkHeaderType { | |
pub protocol: AtomicU32, | ||
|
||
/// The data chunk descriptor | ||
pub segment: AtomicU32, | ||
pub chunk: AtomicU32, | ||
pub len: AtomicUsize, | ||
segment: AtomicU32, | ||
chunk: AtomicU32, | ||
len: AtomicUsize, | ||
} | ||
|
||
impl ChunkHeaderType { | ||
pub fn set_data_descriptor(&self, descriptor: &ChunkDescriptor) { | ||
self.segment.store(descriptor.segment, Ordering::Relaxed); | ||
self.chunk.store(descriptor.chunk, Ordering::Relaxed); | ||
self.len.store(descriptor.len.into(), Ordering::Relaxed); | ||
} | ||
|
||
pub fn data_descriptor(&self) -> ChunkDescriptor { | ||
ChunkDescriptor::new( | ||
self.segment.load(Ordering::Relaxed), | ||
self.chunk.load(Ordering::Relaxed), | ||
// SAFETY: this is safe because Write access to self.len is available only from set_data_descriptor | ||
unsafe { NonZeroUsize::new_unchecked(self.len.load(Ordering::Relaxed)) }, | ||
) | ||
} | ||
} |
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