-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
RFC: Rename Share to Sync #123
RFC: Rename Share to Sync #123
Conversation
Allow me to commence the bikeshedding: I propose the name |
|
Most of the time, ‘thread-safe’ is written with a hyphen or a space, and so should be counted as two words. That would make this trait I personally don’t like the name Another option would be to just use the word ‘aliasable’ to refer to @schmee |
Sync +1 |
You can't call it |
I like the succinctness of When I think of "sync" I think of "synchronized" which often refers to blocking threads or coordinating to wait for an event to happen. This trait implies that a type is sharable among many threads which at its bare minimum means that appropriate atomic operations are used. These two concepts seem similar, but distinct. For example, I would not think of an That being said, I think the drawbacks of |
Based on your arguments above, I think that EDIT: this also has a nice likeness with atoms in Clojure, which are used to "...provide a way to manage shared, synchronous, independent state". |
Threadsafe and Thread have the issue that they would become the most prominent use of the word "thread", which is otherwise not used much since Rust is based on tasks, and they are slightly wrong since the issue is task-safety and not thread-safety (although they are usually equivalent). "Tasksafe" would fix that, but is not a widely used term. Atomic is problematic since it usually implies that atomic CPU instructions or similar mechanisms are being used. Atom is problematic since it is usually either a synonym of Atomic or refers to an interned string type, or to terminal symbols in parsing, or in general to an immutable primitive-valued constant. Sync and Synchronized are problematic because they usually imply that a synchronization primitive is being used. Parallel is problematic because it usually implies that the compiler or library is making some effort to parallelize computation using the type, or that the type is a parallelizable variant of a data structure available in non-parallelizable versions too. DataRaceFree is multi-word and vague. ConcurrentlySharable is too long. This leaves Concurrent (a bit long, maybe a bit vague), Share (a bit vague), Threadsafe (slightly incorrect and a bit long) or Tasksafe (unusual). |
|
Perhaps rename share is a mistake?
|
+1 for |
I like |
EDIT: I made a dumb comment. It is below for reference. Don't read it.
|
I'm told 'Share' is a bound I would need for closures that are safe for data-parallel iterators. I very much hope immutable closures are a case that can be expressed after closure reform - since immutable means its' threadsafe aswell - but also makes inputs / outputs / side-effects clearer. (immutable is suitable for the data-parallel case, and communicates more information about what code does & doesn't do) |
+1 for Share |
What about using |
For the sake of bikeshedding, I'd prefer to keep built-in traits a 1-word long. I think |
As discussed in today's meeting I have updated the name to |
At first I thought that
However, I don't understand why the documentation states that "there is no possibility of data races when passing &T references between tasks", that is, how it is possible to pass any reference between tasks at all? As far as I understand (and I tripped over this several times) no reference other than Probably if the documentation on |
There's no safe way to pass This behaviour is designed to allow fork-join/data-parallelism libraries to expose safe and performant interfaces (even if they have to use /// call `func` on each element of `data` in its own task, blocking until
/// all tasks complete.
fn par_apply<T: Share>(data: &[T], func: fn(&T)) {
// (raw function pointer until the nicer closures work)
unsafe { ... }
} This function is safe because each |
So |
No, that's not what That is, the (Just to be clear, I'm not arguing in favour of any name, just clearing misconceptions.) |
Thanks for thorough explanation. The situation you're describing is not really obvious from
I was speaking from implementation's point of view, of course, that is, I meant that it is possible to actually use
Yeah, I probably should have expressed myself better. What I meant is that |
In my opinion Concurrent is the most suitable name, Sync is a bit too short and implies that the object is actually synchronized, which it doesn't necessarily have to be to be safe |
In particular: * The RFC associated with rust-lang#127 should have had a link to rust-lang#19 as well (and has been assigned RFC rust-lang#19); it also was revised to match the markdown href style of other RFCs. * RFC rust-lang#34 needed its header entries filled in, * RFC rust-lang#123 had a typo in its header, and * RC rust-lang#155 was revised to match the markdown href style of other RFCs.
Rendered