From 15652f73471ff931952b820f0005091ad6fe22a4 Mon Sep 17 00:00:00 2001 From: Erki Date: Tue, 22 Jun 2021 16:22:11 +0300 Subject: [PATCH] Threads: fix actor and signal requirements Trivially copyable and default constructible should be sufficient, as it allows for memcpy and a T{} ctor. --- Threads/Inc/threads_actor.hpp | 4 ++-- Threads/Inc/threads_signal.hpp | 3 ++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/Threads/Inc/threads_actor.hpp b/Threads/Inc/threads_actor.hpp index 50c51b1..a3cd524 100644 --- a/Threads/Inc/threads_actor.hpp +++ b/Threads/Inc/threads_actor.hpp @@ -26,7 +26,7 @@ class Actor public: using value_type = T; - static_assert(std::is_trivially_constructible_v, "T must be trivially constructible."); + static_assert(std::is_default_constructible_v, "T must be default constructible."); static_assert(std::is_trivially_copyable_v, "T must be trivially copyable."); Actor(const std::uint32_t queue_size, const char* name, const osPriority_t priority, const std::uint32_t stack_size) @@ -57,7 +57,7 @@ private: { init(); - value_type data; + value_type data{}; while (true) { diff --git a/Threads/Inc/threads_signal.hpp b/Threads/Inc/threads_signal.hpp index 16dd49a..d6dd057 100644 --- a/Threads/Inc/threads_signal.hpp +++ b/Threads/Inc/threads_signal.hpp @@ -20,7 +20,8 @@ struct Signallable { using value_type = T; - static_assert(std::is_trivially_constructible_v, "T must be trivially constructible."); + 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 bool emit(const T& t) = 0; virtual std::pair emitFromIsr(const T& t) = 0;