Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Allow a fiber in HOLD state to be reset bypassing scope(exit) etc. #1252

Merged
merged 3 commits into from
May 7, 2015
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 8 additions & 3 deletions src/core/thread.d
Original file line number Diff line number Diff line change
Expand Up @@ -4013,14 +4013,19 @@ class Fiber

/**
* Resets this fiber so that it may be re-used, optionally with a
* new function/delegate. This routine may only be called for
* new function/delegate. This routine should only be called for
* fibers that have terminated, as doing otherwise could result in
* scope-dependent functionality that is not executed.
* Stack-based classes, for example, may not be cleaned up
* properly if a fiber is reset before it has terminated.
* properly if a fiber is reset before it has terminated. Calling it
* for a fiber in state HOLD also won't cleanup the old stack,
* so it may leak resources which will lead to stack overflow if reset
* is called too many times for such a fiber. It will
* properly reset the stack though, so the fiber should behave like
* a new one.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's actually much more confusing than before.

One should only reset a fiber in term state, because resetting it in hold state won't cleanup the stack, e.g. scope(exit) and struct destructors aren't called.

*
* In:
* This fiber must be in state TERM.
* This fiber must be in state TERM or HOLD.
*/
final void reset() nothrow
in
Expand Down