[Issue 13916] Nested std.concurrency.receive doesn't work correctly
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 31 17:38:52 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=13916
Seb <greensunny12 at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |greensunny12 at gmail.com
--- Comment #2 from Seb <greensunny12 at gmail.com> ---
So I experimented with removing the message from the list before the handler is
called, but I always get a LinkTerminated Exception which comes from the child
being terminated.
The child is in a while(true) loop, so it shouldn't get terminated, but for
some reason now its module deconstructor is now immediately called :/
diff --git a/std/concurrency.d b/std/concurrency.d
index 0e1b505bc..1c426bcc0 100644
--- a/std/concurrency.d
+++ b/std/concurrency.d
@@ -1974,8 +1980,9 @@ private
enum timedWait = false;
}
- bool onStandardMsg(ref Message msg)
+ bool onStandardMsg(ref Message msg, void delegate() beforeSuccess
= (){})
{
foreach (i, t; Ops)
{
alias Args = Parameters!(t);
@@ -1985,10 +1992,13 @@ private
{
static if (is(ReturnType!(t) == bool))
{
- return msg.map(op);
+ beforeSuccess();
+ auto b = msg.map(op);
+ return b;
}
else
{
+ beforeSuccess();
msg.map(op);
return true;
}
@@ -2043,6 +2053,8 @@ private
{
for (auto range = list[]; !range.empty;)
{
+ import std.stdio;
+ writefln("range: %s", range.front);
// Only the message handler will throw, so if this occurs
// we can be certain that the message was handled.
scope (failure)
@@ -2071,11 +2083,9 @@ private
}
else
{
- if (onStandardMsg(range.front))
- {
- list.removeAt(range);
+ if (onStandardMsg(range.front, (){
list.removeAt(range); }))
return true;
- }
+
range.popFront();
continue;
}
```
--
More information about the Digitalmars-d-bugs
mailing list