View source code
Display the source code in core/thread/fiber/package.d from which thispage was generated on github.
Report a bug
If you spot a problem with this page, click here to create aBugzilla issue.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.Requires a signed-in GitHub account. This works well for small changes.If you'd like to make larger changes you may want to consider usinglocal clone.

Class core.thread.fiber.Fiber

This class provides a cooperative concurrency mechanism integrated with the threading and garbage collection functionality. Calling a fiber may be considered a blocking operation that returns when the fiber yields (via Fiber.yield()). Execution occurs within the context of the calling thread so synchronization is not necessary to guarantee memory visibility so long as the same thread calls the fiber each time. Please note that there is no requirement that a fiber be bound to one specific thread. Rather, fibers may be freely passed between threads so long as they are not currently executing. Like threads, a new fiber thread may be created using either derivation or composition, as in the following example.

class Fiber
  : core.thread.fiber.base.FiberBase;

Constructors

NameDescription
this (fn, sz, guardPageSize) Initializes a fiber object which is associated with a static D function.
this (dg, sz, guardPageSize) Initializes a fiber object which is associated with a dynamic D function.

Methods

NameDescription
getThis () Provides a reference to the calling fiber or null if no fiber is currently active.
allocStack (sz, guardPageSize)

Warning

Status registers are not saved by the current implementations. This means floating point exception status bits (overflow, divide by 0), rounding mode and similar stuff is set per-thread, not per Fiber!

Warning

On ARM FPU registers are not saved if druntime was compiled as ARM_SoftFloat. If such a build is used on a ARM_SoftFP system which actually has got a FPU and other libraries are using the FPU registers (other code is compiled as ARM_SoftFP) this can cause problems. Druntime must be compiled as ARM_SoftFP in this case.

Authors

Sean Kelly, Walter Bright, Alex Rønne Petersen, Martin Nowak

License

Distributed under the Boost Software License 1.0. (See accompanying file LICENSE)