You will learn the usage of fibers in this lesson.

We'll cover the following

Common operations of fibers

The following are common operations of fibers.

  • A fiber starts its execution from a callable entity (function pointer, delegate, etc.) that does not take any parameter and does not return anything. For example, the following function can be used as a fiber function:

    void fiberFunction() {
        // ...
  • A fiber can be created as an object of core.thread.Fiber class with a callable entity:

    import core.thread;
     // ...
        auto fiber = new Fiber(&fiberFunction);

    Alternatively, a subclass of Fiber can be defined, and the fiber function can be passed to the constructor of the superclass. In the following example, the fiber function is a member function:

Get hands-on with 1200+ tech skills courses.