/* * threads_signal.hpp * * Created on: Jun 20, 2021 * Author: erki */ #ifndef THREADS_INC_THREADS_SIGNAL_HPP_ #define THREADS_INC_THREADS_SIGNAL_HPP_ #include #include #include namespace Threads { class PrimitiveThread; template struct Signallable { using value_type = T; static_assert(std::is_trivially_copyable_v, "T must be trivially copyable."); static_assert(std::is_default_constructible_v, "T must be default constructible."); virtual void emit(const T& t) = 0; virtual BaseType_t emitFromIsr(const T& t) = 0; }; template<> struct Signallable { using value_type = void; virtual void emit() = 0; virtual BaseType_t emitFromIsr() = 0; }; template struct Awaitable { using result_type = R; #ifdef INCLUDE_xTaskGetCurrentTaskHandle virtual result_type await() = 0; virtual result_type await(const long timeout) = 0; #endif virtual result_type await(const PrimitiveThread& currentThread) = 0; virtual result_type await(const PrimitiveThread& currentThread, const long timeout) = 0; }; }// namespace Threads #endif /* THREADS_INC_THREADS_SIGNAL_HPP_ */