Zth (libzth)
zth::TypedFiber< R, F > Class Template Referenceabstract

#include <async.h>

Inheritance diagram for zth::TypedFiber< R, F >:
zth::Fiber zth::Listable< Fiber > zth::UniqueID< Fiber > zth::UniqueIDBase

Public Types

typedef R Return
 
typedef F Function
 
typedef Future< ReturnFuture_type
 
- Public Types inherited from zth::Fiber
enum  State {
  Uninitialized = 0 , New , Ready , Running ,
  Waiting , Suspended , Dead
}
 
typedef void() FiberHook(Fiber &)
 
typedef ContextAttr::EntryArg EntryArg
 
typedef void(* Entry) (EntryArg)
 
- Public Types inherited from zth::Listable< Fiber >
typedef Fiber type
 

Public Member Functions

 TypedFiber (Function function)
 
virtual ~TypedFiber () override=default
 
void registerFuture (Future_type *future)
 
Future_typefuture () const
 
SharedPointer< Future_typewithFuture ()
 
- Public Member Functions inherited from zth::Fiber
 Fiber (Entry entry, EntryArg arg=EntryArg())
 
virtual ~Fiber () override
 
int setStackSize (size_t size) noexcept
 
size_t stackSize () const noexcept
 
size_t stackUsage () const
 
Contextcontext () 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 addCleanup (void(*f)(Fiber &, void *), void *arg)
 
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< Fiber >
constexpr Listable () noexcept
 
constexpr Listable (Listable const &e) noexcept
 
 Listable (Listable &&l) noexcept
 
Listableoperator= (Listable const &rhs) noexcept
 
Listableoperator= (Listable &&l) noexcept
 
typelistNext () const noexcept
 
typelistPrev () const 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)
 
UniqueIDoperator= (UniqueID const &)=delete
 
UniqueIDoperator= (UniqueID &&u) noexcept
 
virtual ~UniqueID ()=default
 
void const * normptr () const noexcept
 
uint64_t id () const noexcept
 
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 override
 

Protected Member Functions

virtual void entry_ ()=0
 
template<typename T >
void setFuture (T const &r)
 
void setFuture ()
 
Function function () const noexcept
 
- Protected Member Functions inherited from zth::Fiber
virtual void changedName (string const &name) override
 
void setState (State state, Timestamp const &t=Timestamp::now()) noexcept
 
void fiberEntry_ () noexcept
 
- Protected Member Functions inherited from zth::UniqueIDBase
virtual ~UniqueIDBase ()=default
 

Static Protected Member Functions

static void entry (void *that)
 
- Static Protected Member Functions inherited from zth::Fiber
static void fiberEntry (void *that) noexcept
 

Additional Inherited Members

- Static Public Member Functions inherited from zth::UniqueID< Fiber >
static uint64_t getID () noexcept
 
- Public Attributes inherited from zth::Listable< Fiber >
Listableprev
 
Listableleft
 
Listablenext
 
Listableright
 
- Static Public Attributes inherited from zth::Fiber
static FiberHookhookNew = nullptr
 Hook to be called when a Fiber is created. More...
 
static FiberHookhookDead = nullptr
 Hook to be called when a Fiber is destroyed. More...
 
static uintptr_t const ExitUnknown = (uintptr_t)-1
 

Detailed Description

template<typename R, typename F>
class zth::TypedFiber< R, F >

Definition at line 40 of file async.h.

Member Typedef Documentation

◆ Function

template<typename R , typename F >
typedef F zth::TypedFiber< R, F >::Function

Definition at line 44 of file async.h.

◆ Future_type

template<typename R , typename F >
typedef Future<Return> zth::TypedFiber< R, F >::Future_type

Definition at line 45 of file async.h.

◆ Return

template<typename R , typename F >
typedef R zth::TypedFiber< R, F >::Return

Definition at line 43 of file async.h.

Constructor & Destructor Documentation

◆ TypedFiber()

template<typename R , typename F >
zth::TypedFiber< R, F >::TypedFiber ( Function  function)
inlineexplicit

Definition at line 47 of file async.h.

◆ ~TypedFiber()

template<typename R , typename F >
virtual zth::TypedFiber< R, F >::~TypedFiber ( )
overridevirtualdefault

Member Function Documentation

◆ entry()

template<typename R , typename F >
static void zth::TypedFiber< R, F >::entry ( void *  that)
inlinestaticprotected

Definition at line 80 of file async.h.

◆ entry_()

template<typename R , typename F >
virtual void zth::TypedFiber< R, F >::entry_ ( )
protectedpure virtual

◆ function()

template<typename R , typename F >
Function zth::TypedFiber< R, F >::function ( ) const
inlineprotectednoexcept

Definition at line 101 of file async.h.

◆ future()

template<typename R , typename F >
Future_type* zth::TypedFiber< R, F >::future ( ) const
inline

Definition at line 60 of file async.h.

◆ registerFuture()

template<typename R , typename F >
void zth::TypedFiber< R, F >::registerFuture ( Future_type future)
inline

Definition at line 54 of file async.h.

◆ setFuture() [1/2]

template<typename R , typename F >
void zth::TypedFiber< R, F >::setFuture ( )
inlineprotected

Definition at line 95 of file async.h.

◆ setFuture() [2/2]

template<typename R , typename F >
template<typename T >
void zth::TypedFiber< R, F >::setFuture ( T const &  r)
inlineprotected

Definition at line 89 of file async.h.

◆ withFuture()

template<typename R , typename F >
SharedPointer<Future_type> zth::TypedFiber< R, F >::withFuture ( )
inline

Definition at line 65 of file async.h.


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