kaist-cp / circ

CIRC: Concurrent Immediate Reference Counting
Apache License 2.0
46 stars 3 forks source link

Strengthening documentation; When to use `Rc` and when to use `AtomicRc` and others #7

Open simnalamburt opened 1 month ago

simnalamburt commented 1 month ago

From what I understand, the relationship between circ’s Rc and AtomicRc differs from std’s Rc and Arc. Unlike std::rc::Rc, circ::Rc is thread-safe and resembles a faster version of std::sync::Arc. Despite its name, circ::AtomicRc serves a different role compared to std::sync::Arc, and there is no direct equivalent in std for circ::AtomicRc. It is closer to an atomic version of Arc<Mutex<T>> or a safe and reference-counted std::sync::atomic::AtomicPtr.

Therefore, I suggest enhancing the module-level documentation of circ to clarify when to use circ::Rc and when to use circ::AtomicRc and others. Although it’s possible to determine this by thoroughly reading through the existing documentation, I believe a simplified guide would be more user-friendly. Something akin to the list format found in Rust’s standard library documentation for collections would be ideal. What are your thoughts on this suggestion?

P.S. While I think it might be worth considering renaming circ::AtomicRc, I haven’t come up with a better alternative yet.

Lee-Janggun commented 1 month ago

Renaming AtomicRc: AtomicPtrRc or AtomicRcPtr is more descriptive.

simnalamburt commented 1 month ago

I think a name that explains how users should use the type (i.e. MutableRc?), rather than a more technical name like AtomicPtrRc or AtomicRcPtr that describes its internal structure, would be more suitable.

However, for now, let’s focus more on documentation. If the documentation is well-written, users will still be able to use it even if the name is a bit unconventional.