-
Notifications
You must be signed in to change notification settings - Fork 9
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
Thread-safe management of messages #36
Comments
The handling of messages is already thread-safe, but there is a problem in some places where users could build Senders out of unshared objects and then later have operations where these Senders are executed in a different execution context. An interesting idea is to allow it until it crosses a thread boundary. That way it would be ok in a single-thread fiber application. (Although we probably want to allow moving fibers across threads, so it likely is marginal). Ultimately there are a few cases with regards to shared data:
Anything else should be an error. Case 2 is difficult. D can't really express a unique reference on a language level (it is the missing piece). There is std.typecons.Unique but it requires the thing to be on the heap. The question is, how do you get it on the heap? You need to construct it there. That is problematic since how many things do you know that return a
Absolutely not. No hidden
I started out with inferring @safe. But since you often create long chains of operations it becomes a nightmare to debug when it isn't inferred where you think it should. Another issue is the fact that the library uses delegates instead of alias lambda template parameters. Instead of inferring the library requires delegates to be @safe to begin with and then guarantees everything to be @safe. The nice thing is that if the delegate isn't @safe (or @trusted as escape hatch), you will get a good compiler error. |
Handling of messages should be thread-safe by default. This requires a message type
T
to either!hasAliasing!T
)is(T == Unique!U, U)
Would it be motivated to expose concurrency operations that requires shallow or deep duplication of messages via calls to .dup ?
It might be useful/relevant to have concurrency operations be inferred @safe when the messages it operates on fulfills any of the properties above.
Unique
messages that copies some test case fromjust
. Test assetion could do, for instance,The text was updated successfully, but these errors were encountered: