Threads: make actor and timer classes slightly more debuggable
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
f4649142e5
commit
c0f1ca6a87
@ -32,11 +32,7 @@ public:
|
|||||||
static_assert(std::is_trivially_copyable_v<value_type>, "Ts must be trivially copyable.");
|
static_assert(std::is_trivially_copyable_v<value_type>, "Ts must be trivially copyable.");
|
||||||
|
|
||||||
Actor(const std::uint32_t queue_size, const char* name, const osPriority_t priority, const std::uint32_t stack_size)
|
Actor(const std::uint32_t queue_size, const char* name, const osPriority_t priority, const std::uint32_t stack_size)
|
||||||
: thread_([](void* d) {
|
: thread_(&Actor<CRTP, Ts...>::threadHandler_, this, name, priority, stack_size),
|
||||||
auto* dd = static_cast<Actor<CRTP, Ts...>*>(d);
|
|
||||||
(*dd)();
|
|
||||||
},
|
|
||||||
this, name, priority, stack_size),
|
|
||||||
msg_queue_(xQueueCreate(queue_size, sizeof(value_type))), signal_(this)
|
msg_queue_(xQueueCreate(queue_size, sizeof(value_type))), signal_(this)
|
||||||
{
|
{
|
||||||
assert(msg_queue_);
|
assert(msg_queue_);
|
||||||
@ -129,6 +125,12 @@ private:
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void threadHandler_(void* d)
|
||||||
|
{
|
||||||
|
auto* dd = static_cast<Actor<CRTP, Ts...>*>(d);
|
||||||
|
(*dd)();
|
||||||
|
}
|
||||||
|
|
||||||
Signal<value_type> signal_;
|
Signal<value_type> signal_;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -82,7 +82,8 @@ void Timer::timeoutHandler_(TimerHandle_t timer)
|
|||||||
if (!source)
|
if (!source)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
static_cast<Timer*>(source)->signal_->emit(TimeoutSignal{});
|
auto* d = static_cast<Timer*>(source);
|
||||||
|
d->signal_->emit(TimeoutSignal{});
|
||||||
}
|
}
|
||||||
|
|
||||||
}// namespace Threads
|
}// namespace Threads
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user