Zth (libzth)
Loading...
Searching...
No Matches
zth::Mailbox< T > Class Template Reference

Fiber-aware mailbox. More...

#include <sync.h>

Inheritance diagram for zth::Mailbox< T >:
zth::Synchronizer< 2 > zth::SynchronizerBase zth::RefCounted zth::UniqueID< SynchronizerBase > zth::NamedUniqueID< Named > zth::UniqueIDBase zth::coro::Mailbox< T >

Public Types

typedef T type
 
typedef void * assigned_type
 
- Public Types inherited from zth::Synchronizer< 2 >
typedef SynchronizerBase base
 
- Public Types inherited from zth::UniqueID< SynchronizerBase >
typedef NamedUniqueID base
 

Public Member Functions

 Mailbox (cow_string const &name="Mailbox")
 
 Mailbox (cow_string &&name)
 
virtual ~Mailbox () noexcept override=default
 
bool valid () const noexcept
 
 operator bool () const noexcept
 
bool can_put () const noexcept
 
bool can_take () const noexcept
 
void wait ()
 
void wait_empty ()
 
void put (type const &value)
 
Mailboxoperator= (type const &value)
 
void put (type &&value)
 
Mailboxoperator= (type &&value)
 
type take ()
 
- Public Member Functions inherited from zth::Synchronizer< 2 >
 Synchronizer ()=default
 
 Synchronizer (cow_string const &name)
 
 Synchronizer (cow_string &&name)
 
virtual ~Synchronizer () noexcept override
 
- Public Member Functions inherited from zth::SynchronizerBase
virtual ~SynchronizerBase () 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
 
- Public Member Functions inherited from zth::UniqueID< SynchronizerBase >
 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 () 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
 

Protected Types

enum  { Queue_Put = 0 , Queue_Take = 1 }
 
- Protected Types inherited from zth::Synchronizer< 2 >
typedef base::queue_type queue_type
 
- Protected Types inherited from zth::SynchronizerBase
typedef List queue_type
 

Protected Member Functions

bool valid (assigned_type assigned) const noexcept
 
virtual void wait (assigned_type assigned)
 
type take (assigned_type assigned)
 
virtual void wakeup (Listable &item, queue_type::user_type user, bool prio, size_t q) noexcept final
 
virtual assigned_type wakeup (Listable &item, queue_type::user_type user, bool prio) noexcept
 
- Protected Member Functions inherited from zth::Synchronizer< 2 >
virtual queue_typequeue (size_t q) final
 
- Protected Member Functions inherited from zth::SynchronizerBase
 SynchronizerBase (cow_string const &name="Synchronizer")
 
 SynchronizerBase (cow_string &&name)
 
queue_type::iterator enqueue (Listable &item, size_t q=0) noexcept
 
void block (size_t q=0)
 
bool unblock (Fiber &f, size_t q=0, bool prio=false) noexcept
 Unblock the specific fiber.
 
ListableunblockFirst (size_t q=0, bool prio=false) noexcept
 
bool unblockAll (size_t q=0, bool prio=false) noexcept
 
bool blockUntil (Timestamp const &timeout, Timestamp const &now=Timestamp::now(), size_t q=0)
 Block, with timeout.
 
bool blockFor (TimeInterval const &timeout, Timestamp const &now=Timestamp::now(), size_t q=0)
 Block, with timeout.
 
- Protected Member Functions inherited from zth::RefCounted
virtual void cleanup () noexcept
 
- Protected Member Functions inherited from zth::UniqueID< SynchronizerBase >
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
 

Additional Inherited Members

- Static Public Member Functions inherited from zth::UniqueID< SynchronizerBase >
static uint64_t getID () noexcept
 

Detailed Description

template<typename T>
class zth::Mailbox< T >

Fiber-aware mailbox.

Definition at line 1299 of file sync.h.

Member Typedef Documentation

◆ assigned_type

template<typename T >
typedef void* zth::Mailbox< T >::assigned_type

Definition at line 1306 of file sync.h.

◆ type

template<typename T >
typedef T zth::Mailbox< T >::type

Definition at line 1305 of file sync.h.

Member Enumeration Documentation

◆ anonymous enum

template<typename T >
anonymous enum
protected
Enumerator
Queue_Put 
Queue_Take 

Definition at line 1302 of file sync.h.

Constructor & Destructor Documentation

◆ Mailbox() [1/2]

template<typename T >
zth::Mailbox< T >::Mailbox ( cow_string const &  name = "Mailbox< T >")
inlineexplicit

Definition at line 1308 of file sync.h.

◆ Mailbox() [2/2]

template<typename T >
zth::Mailbox< T >::Mailbox ( cow_string &&  name)
inlineexplicit

Definition at line 1314 of file sync.h.

◆ ~Mailbox()

template<typename T >
virtual zth::Mailbox< T >::~Mailbox ( )
overridevirtualdefaultnoexcept

Reimplemented in zth::coro::Mailbox< T >.

Member Function Documentation

◆ can_put()

template<typename T >
bool zth::Mailbox< T >::can_put ( ) const
inlinenoexcept

Definition at line 1332 of file sync.h.

◆ can_take()

template<typename T >
bool zth::Mailbox< T >::can_take ( ) const
inlinenoexcept

Definition at line 1337 of file sync.h.

◆ operator bool()

template<typename T >
zth::Mailbox< T >::operator bool ( ) const
inlinenoexcept

Definition at line 1327 of file sync.h.

◆ operator=() [1/2]

template<typename T >
Mailbox & zth::Mailbox< T >::operator= ( type &&  value)
inline

Definition at line 1389 of file sync.h.

◆ operator=() [2/2]

template<typename T >
Mailbox & zth::Mailbox< T >::operator= ( type const &  value)
inline

Definition at line 1375 of file sync.h.

◆ put() [1/2]

template<typename T >
void zth::Mailbox< T >::put ( type &&  value)
inline

Definition at line 1382 of file sync.h.

◆ put() [2/2]

template<typename T >
void zth::Mailbox< T >::put ( type const &  value)
inline

Definition at line 1368 of file sync.h.

◆ take() [1/2]

template<typename T >
type zth::Mailbox< T >::take ( )
inline

Definition at line 1416 of file sync.h.

◆ take() [2/2]

template<typename T >
type zth::Mailbox< T >::take ( assigned_type  assigned)
inlineprotected

Definition at line 1422 of file sync.h.

◆ valid() [1/2]

template<typename T >
bool zth::Mailbox< T >::valid ( ) const
inlinenoexcept

Definition at line 1322 of file sync.h.

◆ valid() [2/2]

template<typename T >
bool zth::Mailbox< T >::valid ( assigned_type  assigned) const
inlineprotectednoexcept

Definition at line 1343 of file sync.h.

◆ wait() [1/2]

template<typename T >
void zth::Mailbox< T >::wait ( )
inline

Definition at line 1349 of file sync.h.

◆ wait() [2/2]

template<typename T >
virtual void zth::Mailbox< T >::wait ( assigned_type  assigned)
inlineprotectedvirtual

Reimplemented in zth::coro::Mailbox< T >, and zth::coro::Mailbox< T >.

Definition at line 1355 of file sync.h.

◆ wait_empty()

template<typename T >
void zth::Mailbox< T >::wait_empty ( )
inline

Definition at line 1362 of file sync.h.

◆ wakeup() [1/2]

template<typename T >
virtual assigned_type zth::Mailbox< T >::wakeup ( Listable item,
queue_type::user_type  user,
bool  prio 
)
inlineprotectedvirtualnoexcept

Definition at line 1448 of file sync.h.

◆ wakeup() [2/2]

template<typename T >
virtual void zth::Mailbox< T >::wakeup ( Listable item,
queue_type::user_type  user,
bool  prio,
size_t  q 
)
inlinefinalprotectedvirtualnoexcept

Reimplemented from zth::SynchronizerBase.

Definition at line 1440 of file sync.h.


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