digitalmars.D - Unsafe, unchecked message-passing with std.concurrency
- Elronnd (6/6) Aug 27 2020 Is there any way to do unsafe, unchecked message-passing using
- Simen =?UTF-8?B?S2rDpnLDpXM=?= (6/13) Aug 27 2020 Since you're fine with unsafe, unchecked - why not just lie to
- Elronnd (9/12) Aug 27 2020 It's bothersome and error-prone. I have to cast the data to
- Petar Kirov [ZombineDev] (3/15) Aug 27 2020 The simplest solution is to write your own wrappers of `send` and
Is there any way to do unsafe, unchecked message-passing using std.concurrency's API? I want to be able to share mutable data without having to qualify it as shared. It looks like the check happens in send(), before passing off data to _send(), which does no checking; but _send is private. Is there any analogous functionality elsewhere in phobos--send_unchecked or similar?
Aug 27 2020
On Thursday, 27 August 2020 at 08:39:49 UTC, Elronnd wrote:Is there any way to do unsafe, unchecked message-passing using std.concurrency's API? I want to be able to share mutable data without having to qualify it as shared. It looks like the check happens in send(), before passing off data to _send(), which does no checking; but _send is private. Is there any analogous functionality elsewhere in phobos--send_unchecked or similar?Since you're fine with unsafe, unchecked - why not just lie to the compiler? Cast the data to shared and send it on its merry way? -- Simen
Aug 27 2020
On Thursday, 27 August 2020 at 08:46:31 UTC, Simen Kjærås wrote:Since you're fine with unsafe, unchecked - why not just lie to the compiler? Cast the data to shared and send it on its merry way?It's bothersome and error-prone. I have to cast the data to shared. I also have to remember to receive a shared object on the other side (and if I forget, I won't get a compile error, stuff will just silently break). Once I've received it, I have to cast away the shared again if I want to be able to use the object for anything. I'll do that if I have to, (or write my message-passing library, or repurpose one from C), but would be nice if there were another solution.
Aug 27 2020
On Thursday, 27 August 2020 at 08:59:45 UTC, Elronnd wrote:On Thursday, 27 August 2020 at 08:46:31 UTC, Simen Kjærås wrote:The simplest solution is to write your own wrappers of `send` and `receive` and have them do the casting for you.Since you're fine with unsafe, unchecked - why not just lie to the compiler? Cast the data to shared and send it on its merry way?It's bothersome and error-prone. I have to cast the data to shared. I also have to remember to receive a shared object on the other side (and if I forget, I won't get a compile error, stuff will just silently break). Once I've received it, I have to cast away the shared again if I want to be able to use the object for anything. I'll do that if I have to, (or write my message-passing library, or repurpose one from C), but would be nice if there were another solution.
Aug 27 2020