|
Zth (libzth)
|
Classes | |
| struct | zth::setStackSize |
| Change the stack size of a fiber returned by zth_async. More... | |
| struct | zth::setName |
| Change the name of a fiber returned by zth_async. More... | |
| struct | zth::passOnExit |
| Makes the fiber pass the given gate upon exit. More... | |
| struct | zth::asFuture |
| Forces the fiber to have a future that outlives the fiber. More... | |
| struct | zth::fiber_future< T > |
| The future returned by a fiber. More... | |
| class | zth::joiner |
| RAII class to join fibers and futures on destruction. More... | |
| class | zth::PeriodicWakeUp |
| Periodic wakeup after fixed interval. More... | |
| class | zth::Worker |
| The class that manages the fibers within this thread. More... | |
Functions | |
| template<typename F > | |
| fiber_type< F >::factory | zth::factory (F &&f, char const *name=nullptr) |
| Create a new fiber. | |
| template<typename F , typename... Args> | |
| fiber_type< F >::fiber | zth::fiber (F &&f, Args &&... args) |
| Create and start a new fiber. | |
| void * | zth::fls () noexcept |
| Return the fiber-local storage, as set by setFls(). | |
| void | zth::setFls (void *data=nullptr) noexcept |
| Set the fiber-local storage. | |
| void | zth::waitUntil (TimedWaitable &w) |
| Wait until the given Waitable has passed. | |
| template<typename F , typename std::enable_if<!std::is_base_of< TimedWaitable, F >::value, int >::type = 0> | |
| void | zth::waitUntil (F f, TimeInterval const &pollInterval=TimeInterval()) |
Wait until the given function f returns true. | |
| template<typename C > | |
| void | zth::waitUntil (C &that, bool(C::*f)(), TimeInterval const &pollInterval=TimeInterval()) |
Wait until the given member function f returns true. | |
| void | zth::nap (Timestamp const &sleepUntil) |
| Sleep until the given time stamp. | |
| void | zth::nap (TimeInterval const &sleepFor) |
| Sleep for the given time interval. | |
| void | zth::mnap (long sleepFor_ms) |
| Sleep for the given amount of milliseconds. | |
| void | zth::unap (long sleepFor_us) |
| Sleep for the given amount of microseconds. | |
| Worker & | zth::currentWorker () noexcept |
| Return the (thread-local) singleton Worker instance. | |
| Fiber & | zth::currentFiber () noexcept |
| Return the currently executing fiber. | |
| void | zth::yield (Fiber *preferFiber=nullptr, bool alwaysYield=false, Timestamp const &now=Timestamp::now()) |
| Allow a context switch. | |
| void | zth::outOfWork () |
| Force a context switch. | |
| int | zth::startWorkerThread (void(*f)(), size_t stack, char const *name) |
Start a new thread, create a Worker, with one fiber, which executes f. | |
| int | zth::execlp (char const *file, char const *arg,...) |
| Start an external program. | |
| int | zth::execvp (char const *file, char *const arg[]) |
| Start an external program. | |
|
inlinenoexcept |
Return the currently executing fiber.
|
inlinenoexcept |
| int zth::execlp | ( | char const * | file, |
| char const * | arg, | ||
| ... | |||
| ) |
Start an external program.
Definition at line 93 of file worker.cpp.
| int zth::execvp | ( | char const * | file, |
| char *const | arg[] | ||
| ) |
Start an external program.
Definition at line 153 of file worker.cpp.
| fiber_type< F >::factory zth::factory | ( | F && | f, |
| char const * | name = nullptr |
||
| ) |
| fiber_type< F >::fiber zth::fiber | ( | F && | f, |
| Args &&... | args | ||
| ) |
Create and start a new fiber.
| f | Function/lambda/functor to be executed in the fiber. |
| args | Arguments to be passed to f. |
This function creates and starts a new fiber in one step. It is equivalent to:
|
inlinenoexcept |
|
inline |
Sleep for the given amount of milliseconds.
|
inline |
|
inline |
Sleep until the given time stamp.
|
inline |
Force a context switch.
Normally, yield() does not yield when the time slice did not end. This prevents excessive context switching, without actually doing much work in between. However, if there is no work, this function forces a context switch anyway.
|
inlinenoexcept |
| int zth::startWorkerThread | ( | void(*)() | f, |
| size_t | stack = 0, |
||
| char const * | name = nullptr |
||
| ) |
Start a new thread, create a Worker, with one fiber, which executes f.
Definition at line 62 of file worker.cpp.
|
inline |
| void zth::waitUntil | ( | C & | that, |
| bool(C::*)() | f, | ||
| TimeInterval const & | pollInterval = TimeInterval() |
||
| ) |
| void zth::waitUntil | ( | F | f, |
| TimeInterval const & | pollInterval = TimeInterval() |
||
| ) |
| void zth::waitUntil | ( | TimedWaitable & | w | ) |
Wait until the given Waitable has passed.
Definition at line 25 of file waiter.cpp.
|
inline |
Allow a context switch.
| preferFiber | context switch to this fiber. Do normal scheduling when nullptr. |
| alwaysYield | always perform a context switch, even if we are within Config::MinTimeslice_s(). |
| now | the current time stamp |