https://issues.dlang.org/show_bug.cgi?id=17914

--- Comment #8 from Martin Nowak <[email protected]> ---
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);

--

Reply via email to