-
Notifications
You must be signed in to change notification settings - Fork 58
Add a macro to make initialization easier #103
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
base: master
Are you sure you want to change the base?
Conversation
6bca433
to
6335bb8
Compare
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.
Sounds good to me, thanks! Just a bit of nitpicks and it should be mergable.
9951db6
to
080581e
Compare
@zeenix I have made improvements based on the suggestions, and I added a |
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.
LGTM, thanks!
@JalonWong I'll merge soon but I want to first give others a chance to have a look. CC @adamgreig @sgued |
My only thought is that people are likely to want to configure where the backing store for the heap is located in memory using
|
How about a combination of these two: we add the optional argument for the linker section and if people need to add other attributes, they just don't use the macro? |
6d4171b
to
1e17f59
Compare
@zeenix @adamgreig If someone want to use |
f447854
to
d47bd8a
Compare
/// - This function must be called exactly ONCE. | ||
/// - `size > 0` |
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.
With the assertions in place now, these are no longer a safety issue but rather just panic scenarios, so I'd change the heading here from Safety
to Panics
and update the wording of the section.
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.
I'm not sure how to express it. Could you provide some content?
/// - This function must be called exactly ONCE. | ||
/// - `size > 0` |
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.
Same comment on these.
@@ -8,6 +8,7 @@ use linked_list_allocator::Heap as LLHeap; | |||
/// A linked list first fit heap. | |||
pub struct Heap { | |||
heap: Mutex<RefCell<LLHeap>>, | |||
once_flag: Mutex<Cell<bool>>, |
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.
So my question was that why do we need a separate boolean field with it's own mutex when could use core::cell::OnceCell
? We can bump the MSRV if that's an issue here.
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.
I use Mutex
because it's a hint that we should use it in a critical section. Since the Mutex
of critical_section
is basically an UnsafeCell
, I think it's not bad.
And because Sync
is not implemented for OnceCell
, using it directly might not be safe enough.
No description provided.