Create TactilityFreertos subproject (#440)
This commit is contained in:
committed by
GitHub
parent
a4dc633063
commit
7283920def
@@ -1,6 +1,9 @@
|
||||
#include "Tactility/kernel/SystemEvents.h"
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
|
||||
#include <list>
|
||||
|
||||
namespace tt::kernel {
|
||||
@@ -56,7 +59,7 @@ static const char* getEventName(SystemEvent event) {
|
||||
void publishSystemEvent(SystemEvent event) {
|
||||
TT_LOG_I(TAG, "%s", getEventName(event));
|
||||
|
||||
if (mutex.lock(portMAX_DELAY)) {
|
||||
if (mutex.lock(kernel::MAX_TICKS)) {
|
||||
for (auto& subscription : subscriptions) {
|
||||
if (subscription.event == event) {
|
||||
subscription.handler(event);
|
||||
@@ -68,7 +71,7 @@ void publishSystemEvent(SystemEvent event) {
|
||||
}
|
||||
|
||||
SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent handler) {
|
||||
if (mutex.lock(portMAX_DELAY)) {
|
||||
if (mutex.lock(kernel::MAX_TICKS)) {
|
||||
auto id = ++subscriptionCounter;
|
||||
|
||||
subscriptions.push_back({
|
||||
@@ -85,7 +88,7 @@ SystemEventSubscription subscribeSystemEvent(SystemEvent event, OnSystemEvent ha
|
||||
}
|
||||
|
||||
void unsubscribeSystemEvent(SystemEventSubscription subscription) {
|
||||
if (mutex.lock(portMAX_DELAY)) {
|
||||
if (mutex.lock(kernel::MAX_TICKS)) {
|
||||
std::erase_if(subscriptions, [subscription](auto& item) {
|
||||
return (item.id == subscription);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user