When you assigning the worker in TreeRange, you create a delegate that captures the current TreeRange or 'this'.

---
     worker = new Fiber(&fiberFunc);
---

foreach is defined as (http://dlang.org/statement.html#ForeachStatement):

---
for (auto __r = range; !__r.empty; __r.popFront())
{
    auto e = __r.front;
    ...
}
---

__r is a copy of your range that still refers to the original worker which in turn refers to your original range. So when you popFront, the worker will advance the original range and if you call front you get the element from __r - unadvanced.

That's my best guess.


Reply via email to