|
Zth (libzth)
|
The fiber. More...
#include <fiber.h>
Public Types | |
| enum | State { Uninitialized = 0 , New , Ready , Running , Waiting , Suspended , Dead } |
| typedef void() | FiberHook(Fiber &) |
| typedef ContextAttr::EntryArg | EntryArg |
| typedef void(* | Entry) (EntryArg) |
| typedef Hook< Fiber & > | Hook_type |
Public Types inherited from zth::Listable | |
| typedef void * | user_type |
Public Types inherited from zth::UniqueID< Fiber > | |
| typedef NamedUniqueID | base |
Public Member Functions | |
| Fiber (Entry entry, EntryArg arg=EntryArg()) | |
| virtual | ~Fiber () noexcept override |
| int | setStackSize (size_t size) noexcept |
| size_t | stackSize () const noexcept |
| size_t | stackUsage () const |
| Context * | context () const noexcept |
| State | state () const noexcept |
| void * | fls () const noexcept |
| void | setFls (void *data=nullptr) noexcept |
| Timestamp const & | runningSince () const noexcept |
| Timestamp const & | stateEnd () const noexcept |
| TimeInterval const & | totalTime () const noexcept |
| void | atExit (Hook_type::function_type f, Hook_type::arg_type arg=Hook_type::arg_type()) |
| void | atCleanup (Hook_type::function_type f, Hook_type::arg_type arg=Hook_type::arg_type()) |
| int | init (Timestamp const &now=Timestamp::now()) |
| int | run (Fiber &from, Timestamp now=Timestamp::now()) |
| bool | allowYield (Timestamp const &now=Timestamp::now()) const noexcept |
| void | kill () noexcept |
| void | nap (Timestamp const &sleepUntil=Timestamp::null()) noexcept |
| void | wakeup () noexcept |
| void | suspend () noexcept |
| void | resume () noexcept |
| string | str () const |
Public Member Functions inherited from zth::Listable | |
| constexpr | Listable () noexcept |
| constexpr | Listable (Listable const &e) noexcept |
| Listable & | operator= (Listable const &rhs) noexcept |
| Listable (Listable &&l) noexcept | |
| Listable & | operator= (Listable &&l) noexcept |
Public Member Functions inherited from zth::UniqueID< Fiber > | |
| UniqueID (UniqueID const &)=delete | |
| UniqueID (UniqueID &&u) noexcept | |
| UniqueID (string const &name) | |
| UniqueID (string &&name) | |
| UniqueID (char const *name=nullptr) | |
| UniqueID & | operator= (UniqueID const &)=delete |
| UniqueID & | operator= (UniqueID &&u) noexcept |
| virtual | ~UniqueID () noexcept override=default |
| void const * | normptr () const noexcept |
| uint64_t | id () const noexcept |
Public Member Functions inherited from zth::NamedUniqueID< Named > | |
| virtual | ~NamedUniqueID () noexcept override=default |
| string const & | name () const noexcept |
| void | setName (string const &name) |
| void | setName (char const *name) |
| void | setName (string &&name) |
| virtual char const * | id_str () const noexcept override |
Public Member Functions inherited from zth::RefCounted | |
| RefCounted () noexcept | |
| virtual | ~RefCounted () noexcept |
| void | used () noexcept |
| bool | unused () noexcept |
| size_t | refs () const noexcept |
Static Public Attributes | |
| static FiberHook * | hookNew = nullptr |
| Hook to be called when a Fiber is created. | |
| static FiberHook * | hookDead = nullptr |
| Hook to be called when a Fiber is destroyed. | |
| static uintptr_t const | ExitUnknown = (uintptr_t)-1 |
Protected Member Functions | |
| void | setState (State state, Timestamp const &t=Timestamp::now()) noexcept |
| void | fiberEntry_ () noexcept |
Protected Member Functions inherited from zth::UniqueID< Fiber > | |
| virtual uint64_t | id_ () const noexcept final |
Protected Member Functions inherited from zth::NamedUniqueID< Named > | |
| NamedUniqueID (char const *name=nullptr) | |
| NamedUniqueID (string const &name) | |
| NamedUniqueID (string &&name) | |
Protected Member Functions inherited from zth::UniqueIDBase | |
| virtual | ~UniqueIDBase () noexcept=default |
Protected Member Functions inherited from zth::RefCounted | |
| virtual void | cleanup () noexcept |
Static Protected Member Functions | |
| static void | fiberEntry (void *that) noexcept |
Additional Inherited Members | |
Static Public Member Functions inherited from zth::UniqueID< Fiber > | |
| static uint64_t | getID () noexcept |
The fiber.
This class manages a fiber's context and state, given an entry function.
Usually, don't subclass this class (use zth::Runnable instead), as the zth::Fiber is owned by and part of a zth::Worker's administration. For example, a Fiber object is deleted by the Worker when it is dead.
| typedef Hook<Fiber&> zth::Fiber::Hook_type |
| enum zth::Fiber::State |
|
inlinenoexcept |
|
inline |
|
inline |
|
inlinenoexcept |
|
inlinestaticprotectednoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inline |
|
inlinenoexcept |
|
inlinenoexcept |
|
inlineprotectednoexcept |
|
inlinenoexcept |
|
inlinenoexcept |
|
static |
|
static |
|
static |