-
Notifications
You must be signed in to change notification settings - Fork 13
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
[Closes #371] Use const Default
trait in arena.
#469
Conversation
kernel-rs/src/arena.rs
Outdated
/// ```rust,no_run | ||
/// let arr_arena = ArrayArena::<D, 100>::new_locked("arr_arena"); | ||
/// ``` | ||
pub const fn new_locked<D: Default>(name: &'static str) -> Spinlock<ArrayArena<D, CAPACITY>> { |
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.
new
가 아니라 new_locked
를 만드는 이유는?
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.
...Arena
자체를 접근하는건 arena.rs 내부에서만 해야하고, 외부에서는 항상Spinlock
에 감싸진 형태로 접근해야합니다.- 추가로, 외부에서는
...Arena
를 가지고서는 할 수 있는게 없습니다. (사용할 수 있는 API가 없습니다.)
new
가 Self
를 리턴하는 것보다 Spinlock<Self>
를 리턴하는게 위 사항을 더 잘 나타낸다고 생각하여 변경했습니다.
다만, 혹시 이전으로 다시 되돌리기를 원하시면 말씀해주세요.
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.
* 외부에서는 항상 `Spinlock`에 감싸진 형태로 접근해야합니다.
왜 그런가요? Arena 자체는 spinlock 없이도 API를 잘 만들 수 있는게 아닌가 싶어서 질문드립니다.
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.
다시 new
로 변경했습니다.
지금의 ArrayArena
/MruArena
는 multi thread에서는 사용할 수 없으므로, 항상 Spinlock
에 감싸져있어야해서 이렇게 생각했는데, 말씀하신것처럼 arena를 single thread에서 사용할 수도 있고 이미 MruArena::init
같은 API가 존재하므로, 다시 변경했습니다.
kernel-rs/src/arena.rs
Outdated
/// ```rust,no_run | ||
/// let arr_arena = ArrayArena::<D, 100>::new_locked("arr_arena"); | ||
/// ``` | ||
pub const fn new_locked<D: Default>(name: &'static str) -> Spinlock<ArrayArena<D, CAPACITY>> { |
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.
* 외부에서는 항상 `Spinlock`에 감싸진 형태로 접근해야합니다.
왜 그런가요? Arena 자체는 spinlock 없이도 API를 잘 만들 수 있는게 아닌가 싶어서 질문드립니다.
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.
bors r+
Build succeeded: |
484: Small fix r=Medowhill a=travis1829 매우 간단한 PR입니다. 바로 merge해주셔도 될 것 같습니다. * Fix for #480 (comment) * Fix for #469 (comment) * rustfmt version이 1.4.36-nightly로 업데이트되어, 더 이상 `#[rustfmt::skip]`을 붙일 필요가 없습니다. Co-authored-by: travis1829 <travis1829@naver.com>
Closes #371
Changes
ArrayArena
/MruArena
의new
method를 변경했습니다.기존:
변경 후:
ArrayArena
/MruArena
가 직접 배열을 만들고 초기화합니다.Default
trait을 요구하도록 변경했습니다. (const fn
안에서는 closure나 function pointer를 사용할 수 없는 것으로 보입니다.)Default
trait을const fn
안에서 사용하기 위해서,#![feature(const_impl_trait)]
을 사용했습니다.