-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#31] Solve circular dependency #32
Merged
elfenpiff
merged 4 commits into
eclipse-iceoryx:main
from
elfenpiff:iox2-31-solve-circular-dependency
Dec 14, 2023
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c450af7
[#31] Solve circular dependency between container and memory
elfenpiff 1cd4ba9
[#31] Solve circular dependency between lock_free and memory
elfenpiff 9820a55
[#31] Introduce libacl stub API for docs.rs
elfenpiff 6617fff
[#31] Set version to 0.0.5
elfenpiff File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
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
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2023 Contributors to the Eclipse Foundation | ||
// | ||
// See the NOTICE file(s) distributed with this work for additional | ||
// information regarding copyright ownership. | ||
// | ||
// This program and the accompanying materials are made available under the | ||
// terms of the Apache Software License 2.0 which is available at | ||
// https://www.apache.org/licenses/LICENSE-2.0, or the MIT license | ||
// which is available at https://opensource.org/licenses/MIT. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 OR MIT | ||
|
||
use crate::{allocator::BaseAllocator, math::align}; | ||
use std::sync::atomic::{AtomicUsize, Ordering}; | ||
|
||
/// Simple BumpAllocator for testing purposes. Do not use this in production. If you are looking | ||
/// for a production ready BumpAllocator use the one from iceoryx2_bb_memory::bump_allocator | ||
#[doc(hidden)] | ||
pub struct BumpAllocator { | ||
start: usize, | ||
pos: AtomicUsize, | ||
} | ||
|
||
impl BumpAllocator { | ||
pub fn new(start: usize) -> Self { | ||
Self { | ||
start, | ||
pos: AtomicUsize::new(start), | ||
} | ||
} | ||
} | ||
|
||
impl BaseAllocator for BumpAllocator { | ||
fn allocate( | ||
&self, | ||
layout: std::alloc::Layout, | ||
) -> Result<std::ptr::NonNull<[u8]>, crate::allocator::AllocationError> { | ||
let mem = align(self.pos.load(Ordering::Relaxed), layout.align()); | ||
self.pos.store(mem + layout.size(), Ordering::Relaxed); | ||
|
||
unsafe { | ||
Ok(std::ptr::NonNull::new_unchecked( | ||
std::slice::from_raw_parts_mut(mem as *mut u8, layout.size()), | ||
)) | ||
} | ||
} | ||
|
||
unsafe fn deallocate( | ||
&self, | ||
_ptr: std::ptr::NonNull<u8>, | ||
_layout: std::alloc::Layout, | ||
) -> Result<(), crate::allocator::DeallocationError> { | ||
self.pos.store(self.start, Ordering::Relaxed); | ||
Ok(()) | ||
} | ||
} |
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
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you forget to commit the deleted
bump_allocator
frommemory
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elBoberido Nope, the bump allocator in elementary is a simplistic version for internal tests and documentation the real and good one is stored under memory.
The elementary bump allocator has also the tag
#[doc(hidden)]
with a comment that this is for internal use only.