Skip to content

Commit

Permalink
Fix segfaults in PromiseSender from ldc >= 1.35.0
Browse files Browse the repository at this point in the history
  • Loading branch information
skoppe committed Dec 15, 2023
1 parent 4cdff17 commit 6d31b61
Showing 1 changed file with 10 additions and 16 deletions.
26 changes: 10 additions & 16 deletions source/concurrency/sender.d
Original file line number Diff line number Diff line change
Expand Up @@ -570,18 +570,16 @@ class Promise(T) {
}

SharedBitField!Flags counter;
bool add(DG dg) @safe nothrow shared {
with (unshared) {
with (counter.lock()) {
if (was(Flags.completed)) {
auto val = value.match!((typeof(null)) => assert(0, "not happening"), v => v);
release(); // release early
dg(val);
return true;
} else {
dgs.pushBack(dg);
return false;
}
bool add(DG dg) @trusted nothrow shared {
with(counter.lock()) {
if (was(Flags.completed)) {
auto val = ((cast()this).value).match!((typeof(null)) => assert(0, "not happening"), v => v);
release(); // release early
dg(val);
return true;
} else {
dgs.pushBack(dg);
return false;
}
}
}
Expand All @@ -597,10 +595,6 @@ class Promise(T) {
}
}
}

private auto ref unshared() @trusted nothrow shared {
return cast() this;
}
}

private bool pushImpl(P)(P t) @safe shared nothrow {
Expand Down

0 comments on commit 6d31b61

Please sign in to comment.