thread_safe#

namespace safe#

Typedefs

template<class T>
using alarm_t = std::shared_ptr<alarm_raw_t<T>>#
using mail_t = std::shared_ptr<mail_raw_t>#
using signal_t = event_t<bool>#

Functions

inline void cleanup(mail_raw_t*)#
template<class T>
inline auto lock(const std::weak_ptr<void> &wp)#
template<class T>
alarm_t<T> make_alarm()#
template<class T, class F_Construct, class F_Destruct>
auto make_shared(F_Construct &&fc, F_Destruct &&fd)#
template<class T>
class alarm_raw_t#

Public Types

using status_t = util::optional_t<T>#

Public Functions

inline alarm_raw_t()#
inline void reset()#
inline void ring(const status_t &status)#
inline void ring(status_t &&status)#
inline status_t &status()#
inline const status_t &status() const#
inline auto wait()#
template<class Pred>
inline auto wait(Pred &&pred)#
template<class Rep, class Period>
inline auto wait_for(const std::chrono::duration<Rep, Period> &rel_time)#
template<class Rep, class Period, class Pred>
inline auto wait_for(const std::chrono::duration<Rep, Period> &rel_time, Pred &&pred)#
template<class Rep, class Period>
inline auto wait_until(const std::chrono::duration<Rep, Period> &rel_time)#
template<class Rep, class Period, class Pred>
inline auto wait_until(const std::chrono::duration<Rep, Period> &rel_time, Pred &&pred)#

Private Members

std::condition_variable _cv#
std::mutex _lock#
status_t _status#
template<class T>
class event_t#

Public Types

using status_t = util::optional_t<T>#

Public Functions

inline bool peek()#
inline status_t pop()#
template<class Rep, class Period>
inline status_t pop(std::chrono::duration<Rep, Period> delay)#
template<class ...Args>
inline void raise(Args&&... args)#
inline void reset()#
inline bool running() const#
inline void stop()#
inline const status_t &view()#

Private Members

bool _continue = {true}#
std::condition_variable _cv#
std::mutex _lock#
status_t _status = {util::false_v<status_t>}#
class mail_raw_t : public std::enable_shared_from_this<mail_raw_t>#

Public Types

template<class T>
using event_t = std::shared_ptr<post_t<event_t<T>>>#
template<class T>
using queue_t = std::shared_ptr<post_t<queue_t<T>>>#

Public Functions

inline void cleanup()#
template<class T>
inline event_t<T> event(const std::string_view &id)#
template<class T>
inline queue_t<T> queue(const std::string_view &id)#

Public Members

std::map<std::string, std::weak_ptr<void>, std::less<>> id_to_post#
std::mutex mutex#
template<class T>
class post_t : public T#

Public Functions

template<class ...Args>
inline post_t(mail_t mail, Args&&... args)#
inline ~post_t()#

Public Members

mail_t mail#
template<class T>
class queue_t#

Public Types

using status_t = util::optional_t<T>#

Public Functions

inline bool peek()#
inline status_t pop()#
template<class Rep, class Period>
inline status_t pop(std::chrono::duration<Rep, Period> delay)#
inline queue_t(std::uint32_t max_elements = 32)#
template<class ...Args>
inline void raise(Args&&... args)#
inline bool running() const#
inline void stop()#
inline std::vector<T> &unsafe()#

Private Members

bool _continue = {true}#
std::condition_variable _cv#
std::mutex _lock#
std::uint32_t _max_elements#
std::vector<T> _queue#
template<class T>
class shared_t#

Public Types

using construct_f = std::function<int(element_type&)>#
using destruct_f = std::function<void(element_type&)>#
using element_type = T#

Public Functions

inline ptr_t ref()#
template<class FC, class FD>
inline shared_t(FC &&fc, FD &&fd)#

Private Members

construct_f _construct#
std::uint32_t _count#
destruct_f _destruct#
std::mutex _lock#
std::array<std::uint8_t, sizeof(element_type)> _object_buf#
struct ptr_t#

Public Functions

inline element_type *get() const#
inline operator bool() const#
inline element_type *operator->()#
inline ptr_t &operator=(const ptr_t &ptr) noexcept#
inline ptr_t &operator=(ptr_t &&ptr) noexcept#
inline ptr_t()#
inline ptr_t(const ptr_t &ptr) noexcept#
inline ptr_t(ptr_t &&ptr) noexcept#
inline explicit ptr_t(shared_t *owner)#
inline void release()#
inline ~ptr_t()#

Public Members

shared_t *owner#