-
Notifications
You must be signed in to change notification settings - Fork 14
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
Add the generalized-scope RFC #10
Conversation
|
||
# Motivation | ||
|
||
The `unprotected` function provides a `Scope` without pinning the thread, where the caller thread is |
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.
More precisely (see the Atomic API RFC), the caller thread is either the only one accessing atomics or no one is modifying atomics. This is sort of like a RwLock
.
text/2017-09-04-generalized-scope.md
Outdated
The `unprotected` function provides a `Scope` without pinning the thread, where the caller thread is | ||
the only one accessing atomics. Assuming this, we can **immediately** deallocate and drop objects in | ||
an unprotected scope. However, even in an unprotected scope, the `defer_free` and `defer_drop` | ||
functions defers freeing and dropping the objects until the scope is over. Even worse, if a lot of |
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.
Would it be a good idea to simply remove defer_free
and defer_drop
from UnprotectedScope
?
Why would someone want to call defer_free
or defer_drop
in an unprotected scope?
|
||
- Creating | ||
the | ||
[`Scope` trait](https://github.com/jeehoonkang/crossbeam-epoch/blob/unprotected/src/realm.rs#L15), |
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.
Instead of creating a split between EpochScope
and UnprotectedScope
, why not just put is_unprotected: bool
inside Scope
?
Reviewing only the changes related to First of all, I think it's reasonable to optimize code whenever we can. But in this case I'm wondering if this is the right direction to push optimizations into. Why would someone want to call Is the intention to immediately destroy the If that is indeed the case, perhaps we'd like an unsafe method impl<'scope> Scope<'scope> {
unsafe fn defer_destroy<T: 'static>(&self, ptr: Ptr<'scope, T>) {
let ptr: Ptr<'static, T> = mem::transmute(ptr);
self.defer(move || ptr.destroy());
}
// ...
} |
@stjepang thank you for the feedback! I would like to answer some of your questions. On Unprotected scopes do not need a garbage bag. So using the I very much like the idea of |
I see -- this is indeed a good case for calling
Actually, we don't need an additional boolean field. Here we should just check whether This is a very easy solution, and now there's no need to generalize scopes. :) |
I'm closing it. In #12, we are discussing what will be the right interface for the "realms", which might evolve to an RFC later. |
I am proposing:
Scope
trait, and implementsScope
for the oldScope
struct.unprotected
use a different implementation ofScope
so thatdefer_drop
ped anddefer_free
d objects are immediately dropped and freed.This RFC is fully implemented in this branch.
Rendered