Zth (libzth)
zth::passOnExit Class Reference

Makes the fiber pass the given gate upon exit. More...

#include <async.h>

Inheritance diagram for zth::passOnExit:
zth::FiberManipulator

Public Member Functions

constexpr passOnExit (Gate &gate) noexcept
 
virtual ~passOnExit () override=default
 

Protected Member Functions

virtual void apply (Fiber &fiber) const override
 
- Protected Member Functions inherited from zth::FiberManipulator
constexpr FiberManipulator () noexcept=default
 
virtual ~FiberManipulator ()=default
 

Static Protected Member Functions

static void cleanup (Fiber &f, void *gate)
 

Detailed Description

Makes the fiber pass the given gate upon exit.

Example:

void foo() { ... }
int main_fiber(int argc, char** argv) {
zth::Gate gate(3);
async foo() << zth::passOnExit(gate);
async foo() << zth::passOnExit(gate);
gate.wait();
// If we get here, both foo()s have finished.
return 0;
}
Fiber-aware barrier/gate.
Definition: sync.h:757
Makes the fiber pass the given gate upon exit.
Definition: async.h:229
int main_fiber(int argc, char **argv)
Definition: main.cpp:14
#define zth_fiber(...)
Prepare every given function to become a fiber by async.
Definition: async.h:765
#define async
Run a function as a new fiber.
Definition: async.h:789
Examples
daemon_pattern.cpp.

Definition at line 229 of file async.h.

Constructor & Destructor Documentation

◆ passOnExit()

constexpr zth::passOnExit::passOnExit ( Gate gate)
inlineexplicitconstexprnoexcept

Definition at line 231 of file async.h.

◆ ~passOnExit()

virtual zth::passOnExit::~passOnExit ( )
overridevirtualdefault

Member Function Documentation

◆ apply()

virtual void zth::passOnExit::apply ( Fiber fiber) const
inlineoverrideprotectedvirtual

Implements zth::FiberManipulator.

Definition at line 243 of file async.h.

◆ cleanup()

static void zth::passOnExit::cleanup ( Fiber f,
void *  gate 
)
inlinestaticprotected

Definition at line 238 of file async.h.


The documentation for this class was generated from the following file: