[Issue 17914] [Reg 2.075] Fibers guard page uses a lot more memory mappings
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Oct 27 12:46:14 UTC 2017
https://issues.dlang.org/show_bug.cgi?id=17914
--- Comment #8 from Martin Nowak <code at dawg.eu> ---
We could keep track of the number of unfinalized Fibers with guard pages and
trigger a GC collection when reaching 30K, but that's too hacky for my taste.
> We don't actually need 30k fibers. We need one fiber at a time 30k times in a row.
As for your specific problem Brian, could you use
`std.typecons.scoped!(Generator!T)` which provides deterministic destruction?
Scoped is only moveable, not copyable.
auto gen = scoped!(Generator!int)({yield(42);});
auto gen2 = move(gen); // not copyable
assert(gen2.front == 42);
Potentially if you have unclear ownership over that Generator and cannot
restrict yourself to `move`, you could combine it with `refCounted`, seems like
that combination doesn't work atm. though :/.
auto gen = refCounted(scoped!(Generator!int)({yield(42);}));
auto gen2 = gen; // 2nd reference to generator
assert(gen2.front == 42);
--
More information about the Digitalmars-d-bugs
mailing list