mirror of
https://github.com/bspeice/aeron-rs
synced 2024-12-21 21:38:09 -05:00
Code formatting
This commit is contained in:
parent
b567336bb0
commit
fff850f6b7
@ -67,7 +67,7 @@ pub trait AtomicBuffer: Deref<Target = [u8]> + DerefMut<Target = [u8]> {
|
|||||||
/// NOTE: Has the potential to cause undefined behavior if alignment is incorrect
|
/// NOTE: Has the potential to cause undefined behavior if alignment is incorrect
|
||||||
fn overlay_mut<T>(&mut self, offset: IndexT) -> Result<&mut T>
|
fn overlay_mut<T>(&mut self, offset: IndexT) -> Result<&mut T>
|
||||||
where
|
where
|
||||||
T: Sized
|
T: Sized,
|
||||||
{
|
{
|
||||||
self.bounds_check(offset, size_of::<T>() as IndexT)
|
self.bounds_check(offset, size_of::<T>() as IndexT)
|
||||||
.map(|_| {
|
.map(|_| {
|
||||||
|
@ -77,7 +77,12 @@ fn should_write_to_empty_buffer() {
|
|||||||
fn should_reject_write_when_insufficient_space() {
|
fn should_reject_write_when_insufficient_space() {
|
||||||
let length: IndexT = 100;
|
let length: IndexT = 100;
|
||||||
let head: IndexT = 0;
|
let head: IndexT = 0;
|
||||||
let tail: IndexT = head + (CAPACITY - align((length - record_descriptor::ALIGNMENT) as usize, record_descriptor::ALIGNMENT as usize)) as IndexT;
|
let tail: IndexT = head
|
||||||
|
+ (CAPACITY
|
||||||
|
- align(
|
||||||
|
(length - record_descriptor::ALIGNMENT) as usize,
|
||||||
|
record_descriptor::ALIGNMENT as usize,
|
||||||
|
)) as IndexT;
|
||||||
let src_index: IndexT = 0;
|
let src_index: IndexT = 0;
|
||||||
|
|
||||||
let mut buffer = ManyToOneRingBuffer::new(vec![0u8; BUFFER_SZ]).unwrap();
|
let mut buffer = ManyToOneRingBuffer::new(vec![0u8; BUFFER_SZ]).unwrap();
|
||||||
@ -112,7 +117,10 @@ fn should_reject_write_when_buffer_full() {
|
|||||||
fn should_insert_padding_record_plus_message_on_buffer_wrap() {
|
fn should_insert_padding_record_plus_message_on_buffer_wrap() {
|
||||||
let length: IndexT = 100;
|
let length: IndexT = 100;
|
||||||
let record_length: IndexT = length + record_descriptor::HEADER_LENGTH;
|
let record_length: IndexT = length + record_descriptor::HEADER_LENGTH;
|
||||||
let aligned_record_length = align(record_length as usize, record_descriptor::ALIGNMENT as usize) as IndexT;
|
let aligned_record_length = align(
|
||||||
|
record_length as usize,
|
||||||
|
record_descriptor::ALIGNMENT as usize,
|
||||||
|
) as IndexT;
|
||||||
let tail: IndexT = CAPACITY as IndexT - record_descriptor::ALIGNMENT;
|
let tail: IndexT = CAPACITY as IndexT - record_descriptor::ALIGNMENT;
|
||||||
let head: IndexT = tail - (record_descriptor::ALIGNMENT * 4);
|
let head: IndexT = tail - (record_descriptor::ALIGNMENT * 4);
|
||||||
let src_index: IndexT = 0;
|
let src_index: IndexT = 0;
|
||||||
@ -125,10 +133,25 @@ fn should_insert_padding_record_plus_message_on_buffer_wrap() {
|
|||||||
let write_res = buffer.write(MSG_TYPE_ID, &src_bytes, src_index, length);
|
let write_res = buffer.write(MSG_TYPE_ID, &src_bytes, src_index, length);
|
||||||
assert_eq!(write_res, Ok(true));
|
assert_eq!(write_res, Ok(true));
|
||||||
|
|
||||||
assert_eq!(buffer.get_i32(record_descriptor::type_offset(tail)), Ok(record_descriptor::PADDING_MSG_TYPE_ID));
|
assert_eq!(
|
||||||
assert_eq!(buffer.get_i32(record_descriptor::length_offset(tail)), Ok(record_descriptor::ALIGNMENT));
|
buffer.get_i32(record_descriptor::type_offset(tail)),
|
||||||
|
Ok(record_descriptor::PADDING_MSG_TYPE_ID)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
buffer.get_i32(record_descriptor::length_offset(tail)),
|
||||||
|
Ok(record_descriptor::ALIGNMENT)
|
||||||
|
);
|
||||||
|
|
||||||
assert_eq!(buffer.get_i32(record_descriptor::length_offset(0)), Ok(record_length));
|
assert_eq!(
|
||||||
assert_eq!(buffer.get_i32(record_descriptor::type_offset(0)), Ok(MSG_TYPE_ID));
|
buffer.get_i32(record_descriptor::length_offset(0)),
|
||||||
assert_eq!(buffer.get_i64(TAIL_COUNTER_INDEX), Ok((tail + aligned_record_length + record_descriptor::ALIGNMENT) as i64));
|
Ok(record_length)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
buffer.get_i32(record_descriptor::type_offset(0)),
|
||||||
|
Ok(MSG_TYPE_ID)
|
||||||
|
);
|
||||||
|
assert_eq!(
|
||||||
|
buffer.get_i64(TAIL_COUNTER_INDEX),
|
||||||
|
Ok((tail + aligned_record_length + record_descriptor::ALIGNMENT) as i64)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user