TactilityCore improvements (#187)

FreeRTOS handles were stored plainly and they were deleted in the destructor of classes.
This meant that if a class were to be copied, the destructor would be called twice on the same handles and lead to double-free.

Seha on Discord suggested to fix this by using `std::unique_ptr` with a custom deletion function.

The changes affect:
- Thread
- Semaphore
- Mutex
- StreamBuffer
- Timer
- MessageQueue
- EventFlag

Thread  changes:
- Removal of the hack with the `Data` struct
- Thread's main body is now just a private static function inside the class.
- The C functions were relocated to static class members

PubSub changes:
- Refactored pubsub into class
- Renamed files to `PubSub` instead of `Pubsub`
- `PubSubSubscription` is now a private inner struct and `PubSub` only exposes `SubscriptionHandle`

Lockable, ScopedLockable, Mutex:
- Added `lock()` method that locks indefinitely
- Remove deprecated `acquire()` and `release()` methods
- Removed `TtWaitForever` in favour of `portMAX_DELAY`
This commit is contained in:
Ken Van Hoeylandt
2025-01-25 17:29:11 +01:00
committed by GitHub
parent c2edbad0fb
commit 686f7cce83
60 changed files with 711 additions and 831 deletions
+1 -1
View File
@@ -163,7 +163,7 @@ void run(const Configuration& config) {
TT_LOG_I(TAG, "Processing main dispatcher");
while (true) {
getMainDispatcher().consume(TtWaitForever);
getMainDispatcher().consume();
}
}
+10 -10
View File
@@ -6,15 +6,15 @@ namespace tt::app {
#define TAG "app"
void AppInstance::setState(State newState) {
mutex.acquire(TtWaitForever);
mutex.lock();
state = newState;
mutex.release();
mutex.unlock();
}
State AppInstance::getState() const {
mutex.acquire(TtWaitForever);
mutex.lock();
auto result = state;
mutex.release();
mutex.unlock();
return result;
}
@@ -30,22 +30,22 @@ const AppManifest& AppInstance::getManifest() const {
}
Flags AppInstance::getFlags() const {
mutex.acquire(TtWaitForever);
mutex.lock();
auto result = flags;
mutex.release();
mutex.unlock();
return result;
}
void AppInstance::setFlags(Flags newFlags) {
mutex.acquire(TtWaitForever);
mutex.lock();
flags = newFlags;
mutex.release();
mutex.unlock();
}
std::shared_ptr<const Bundle> AppInstance::getParameters() const {
mutex.acquire(TtWaitForever);
mutex.lock();
std::shared_ptr<const Bundle> result = parameters;
mutex.release();
mutex.unlock();
return result;
}
+6 -6
View File
@@ -15,7 +15,7 @@ static Mutex hash_mutex(Mutex::Type::Normal);
void addApp(const AppManifest& manifest) {
TT_LOG_I(TAG, "Registering manifest %s", manifest.id.c_str());
hash_mutex.acquire(TtWaitForever);
hash_mutex.lock();
if (!app_manifest_map.contains(manifest.id)) {
app_manifest_map[manifest.id] = std::make_shared<AppManifest>(manifest);
@@ -23,13 +23,13 @@ void addApp(const AppManifest& manifest) {
TT_LOG_E(TAG, "App id in use: %s", manifest.id.c_str());
}
hash_mutex.release();
hash_mutex.unlock();
}
_Nullable std::shared_ptr<AppManifest> findAppById(const std::string& id) {
hash_mutex.acquire(TtWaitForever);
hash_mutex.lock();
auto result = app_manifest_map.find(id);
hash_mutex.release();
hash_mutex.unlock();
if (result != app_manifest_map.end()) {
return result->second;
} else {
@@ -39,11 +39,11 @@ _Nullable std::shared_ptr<AppManifest> findAppById(const std::string& id) {
std::vector<std::shared_ptr<AppManifest>> getApps() {
std::vector<std::shared_ptr<AppManifest>> manifests;
hash_mutex.acquire(TtWaitForever);
hash_mutex.lock();
for (const auto& item: app_manifest_map) {
manifests.push_back(item.second);
}
hash_mutex.release();
hash_mutex.unlock();
return manifests;
}
+2 -2
View File
@@ -26,11 +26,11 @@ private:
public:
void lock() const {
tt_check(mutex.acquire(1000) == TtStatusOk);
tt_check(mutex.lock(1000));
}
void unlock() const {
tt_check(mutex.release() == TtStatusOk);
tt_check(mutex.unlock());
}
void onShow(AppContext& app, lv_obj_t* parent) override;
+20 -20
View File
@@ -115,12 +115,12 @@ void I2cScannerApp::onShow(AppContext& app, lv_obj_t* parent) {
void I2cScannerApp::onHide(AppContext& app) {
bool isRunning = false;
if (mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(250 / portTICK_PERIOD_MS)) {
auto* timer = scanTimer.get();
if (timer != nullptr) {
isRunning = timer->isRunning();
}
mutex.release();
mutex.unlock();
} else {
return;
}
@@ -158,9 +158,9 @@ void I2cScannerApp::onScanTimerCallback(TT_UNUSED std::shared_ptr<void> context)
// endregion Callbacks
bool I2cScannerApp::getPort(i2c_port_t* outPort) {
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
*outPort = this->port;
assert(mutex.release() == TtStatusOk);
mutex.unlock();
return true;
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "getPort");
@@ -169,9 +169,9 @@ bool I2cScannerApp::getPort(i2c_port_t* outPort) {
}
bool I2cScannerApp::addAddressToList(uint8_t address) {
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
scannedAddresses.push_back(address);
assert(mutex.release() == TtStatusOk);
mutex.unlock();
return true;
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "addAddressToList");
@@ -180,9 +180,9 @@ bool I2cScannerApp::addAddressToList(uint8_t address) {
}
bool I2cScannerApp::shouldStopScanTimer() {
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
bool is_scanning = scanState == ScanStateScanning;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
return !is_scanning;
} else {
return true;
@@ -222,9 +222,9 @@ void I2cScannerApp::onScanTimer() {
bool I2cScannerApp::hasScanThread() {
bool has_thread;
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
has_thread = scanTimer != nullptr;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
return has_thread;
} else {
// Unsafe way
@@ -238,7 +238,7 @@ void I2cScannerApp::startScanning() {
stopScanning();
}
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
scannedAddresses.clear();
lv_obj_add_flag(scanListWidget, LV_OBJ_FLAG_HIDDEN);
@@ -250,16 +250,16 @@ void I2cScannerApp::startScanning() {
onScanTimerCallback
);
scanTimer->start(10);
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "startScanning");
}
}
void I2cScannerApp::stopScanning() {
if (mutex.acquire(250 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(250 / portTICK_PERIOD_MS)) {
assert(scanTimer != nullptr);
scanState = ScanStateStopped;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
} else {
TT_LOG_E(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED);
}
@@ -271,11 +271,11 @@ void I2cScannerApp::onSelectBus(lv_event_t* event) {
auto i2c_devices = tt::getConfiguration()->hardware->i2c;
assert(selected < i2c_devices.size());
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
scannedAddresses.clear();
port = i2c_devices[selected].port;
scanState = ScanStateInitial;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
updateViews();
}
@@ -293,7 +293,7 @@ void I2cScannerApp::onPressScan(TT_UNUSED lv_event_t* event) {
}
void I2cScannerApp::updateViews() {
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
if (scanState == ScanStateScanning) {
lv_label_set_text(scanButtonLabelWidget, STOP_SCAN_TEXT);
lv_obj_remove_flag(portDropdownWidget, LV_OBJ_FLAG_CLICKABLE);
@@ -317,7 +317,7 @@ void I2cScannerApp::updateViews() {
lv_obj_add_flag(scanListWidget, LV_OBJ_FLAG_HIDDEN);
}
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "updateViews");
}
@@ -333,12 +333,12 @@ void I2cScannerApp::updateViewsSafely() {
}
void I2cScannerApp::onScanTimerFinished() {
if (mutex.acquire(100 / portTICK_PERIOD_MS) == TtStatusOk) {
if (mutex.lock(100 / portTICK_PERIOD_MS)) {
if (scanState == ScanStateScanning) {
scanState = ScanStateStopped;
updateViewsSafely();
}
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
} else {
TT_LOG_W(TAG, LOG_MESSAGE_MUTEX_LOCK_FAILED_FMT, "onScanTimerFinished");
}
+12 -13
View File
@@ -1,47 +1,46 @@
#include "app/wificonnect/State.h"
#include "Check.h"
#include <cstring>
namespace tt::app::wificonnect {
void State::setConnectionError(bool error) {
tt_check(lock.acquire(TtWaitForever) == TtStatusOk);
lock.lock();
connectionError = error;
tt_check(lock.release() == TtStatusOk);
lock.unlock();
}
bool State::hasConnectionError() const {
tt_check(lock.acquire(TtWaitForever) == TtStatusOk);
lock.lock();
auto result = connectionError;
tt_check(lock.release() == TtStatusOk);
lock.unlock();
return result;
}
void State::setApSettings(const service::wifi::settings::WifiApSettings* newSettings) {
tt_check(lock.acquire(TtWaitForever) == TtStatusOk);
lock.lock();
memcpy(&this->apSettings, newSettings, sizeof(service::wifi::settings::WifiApSettings));
tt_check(lock.release() == TtStatusOk);
lock.unlock();
}
const service::wifi::settings::WifiApSettings& State::lockApSettings() {
tt_check(lock.acquire(TtWaitForever) == TtStatusOk);
lock.lock();
return apSettings;
}
void State::unlockApSettings() {
tt_check(lock.release() == TtStatusOk);
lock.unlock();
}
void State::setConnecting(bool isConnecting) {
tt_check(lock.acquire(TtWaitForever) == TtStatusOk);
lock.lock();
connecting = isConnecting;
tt_check(lock.release() == TtStatusOk);
lock.unlock();
}
bool State::isConnecting() const {
tt_check(lock.acquire(TtWaitForever) == TtStatusOk);
lock.lock();
auto result = connecting;
tt_check(lock.release() == TtStatusOk);
lock.unlock();
return result;
}
@@ -56,8 +56,7 @@ static void onConnect(const service::wifi::settings::WifiApSettings* ap_settings
}
WifiConnect::WifiConnect() {
auto wifi_pubsub = service::wifi::getPubsub();
wifiSubscription = tt_pubsub_subscribe(wifi_pubsub, &eventCallback, this);
wifiSubscription = service::wifi::getPubsub()->subscribe(&eventCallback, this);
bindings = (Bindings) {
.onConnectSsid = onConnect,
.onConnectSsidContext = this,
@@ -65,16 +64,15 @@ WifiConnect::WifiConnect() {
}
WifiConnect::~WifiConnect() {
auto pubsub = service::wifi::getPubsub();
tt_pubsub_unsubscribe(pubsub, wifiSubscription);
service::wifi::getPubsub()->unsubscribe(wifiSubscription);
}
void WifiConnect::lock() {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
}
void WifiConnect::unlock() {
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
void WifiConnect::requestViewUpdate() {
+15 -17
View File
@@ -1,63 +1,61 @@
#include <Check.h>
#include "app/wifimanage/WifiManagePrivate.h"
namespace tt::app::wifimanage {
void State::setScanning(bool isScanning) {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
scanning = isScanning;
scannedAfterRadioOn |= isScanning;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
void State::setRadioState(service::wifi::RadioState state) {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
radioState = state;
if (radioState == service::wifi::RadioState::Off) {
scannedAfterRadioOn = false;
}
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
service::wifi::RadioState State::getRadioState() const {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
auto result = radioState;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
return result;
}
bool State::isScanning() const {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
bool result = scanning;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
return result;
}
const std::vector<service::wifi::ApRecord>& State::lockApRecords() const {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
return apRecords;
}
void State::unlockApRecords() const {
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
void State::updateApRecords() {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
apRecords = service::wifi::getScanResults();
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
void State::setConnectSsid(const std::string& ssid) {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
connectSsid = ssid;
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
std::string State::getConnectSsid() const {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
auto result = connectSsid;
tt_check(mutex.release() == TtStatusOk);
return result;
}
@@ -64,11 +64,11 @@ WifiManage::WifiManage() {
}
void WifiManage::lock() {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
}
void WifiManage::unlock() {
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
void WifiManage::requestViewUpdate() {
@@ -111,8 +111,7 @@ static void wifiManageEventCallback(const void* message, void* context) {
}
void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
auto wifi_pubsub = service::wifi::getPubsub();
wifiSubscription = tt_pubsub_subscribe(wifi_pubsub, &wifiManageEventCallback, this);
wifiSubscription = service::wifi::getPubsub()->subscribe(&wifiManageEventCallback, this);
// State update (it has its own locking)
state.setRadioState(service::wifi::getRadioState());
@@ -139,8 +138,7 @@ void WifiManage::onShow(AppContext& app, lv_obj_t* parent) {
void WifiManage::onHide(TT_UNUSED AppContext& app) {
lock();
auto wifi_pubsub = service::wifi::getPubsub();
tt_pubsub_unsubscribe(wifi_pubsub, wifiSubscription);
service::wifi::getPubsub()->unsubscribe(wifiSubscription);
wifiSubscription = nullptr;
isViewEnabled = false;
unlock();
+2 -2
View File
@@ -6,11 +6,11 @@ namespace tt::lvgl {
static Mutex lockMutex;
static bool defaultLock(uint32_t timeoutMillis) {
return lockMutex.acquire(timeoutMillis) == TtStatusOk;
return lockMutex.lock(timeoutMillis);
}
static void defaultUnlock() {
lockMutex.release();
lockMutex.unlock();
}
static LvglLock lock_singleton = defaultLock;
+13 -13
View File
@@ -4,7 +4,7 @@
#include "Statusbar.h"
#include "Mutex.h"
#include "Pubsub.h"
#include "PubSub.h"
#include "TactilityCore.h"
#include "lvgl/Style.h"
@@ -43,10 +43,10 @@ typedef struct {
lv_obj_t* time;
lv_obj_t* icons[STATUSBAR_ICON_LIMIT];
lv_obj_t* battery_icon;
PubSubSubscription* pubsub_subscription;
PubSub::SubscriptionHandle pubsub_subscription;
} Statusbar;
static bool statusbar_lock(uint32_t timeoutTicks) {
static bool statusbar_lock(uint32_t timeoutTicks = portMAX_DELAY) {
return statusbar_data.mutex.lock(timeoutTicks);
}
@@ -83,7 +83,7 @@ static void onUpdateTime(TT_UNUSED std::shared_ptr<void> context) {
statusbar_data.time_update_timer->start(getNextUpdateTime());
// Notify widget
tt_pubsub_publish(statusbar_data.pubsub, nullptr);
statusbar_data.pubsub->publish(nullptr);
} else {
statusbar_data.time_update_timer->start(pdMS_TO_TICKS(60000U));
}
@@ -132,7 +132,7 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
lv_obj_remove_flag(obj, LV_OBJ_FLAG_SCROLLABLE);
LV_TRACE_OBJ_CREATE("finished");
auto* statusbar = (Statusbar*)obj;
statusbar->pubsub_subscription = tt_pubsub_subscribe(statusbar_data.pubsub, &statusbar_pubsub_event, statusbar);
statusbar->pubsub_subscription = statusbar_data.pubsub->subscribe(&statusbar_pubsub_event, statusbar);
if (!statusbar_data.time_update_timer->isRunning()) {
statusbar_data.time_update_timer->start(50 / portTICK_PERIOD_MS);
@@ -145,7 +145,7 @@ static void statusbar_constructor(const lv_obj_class_t* class_p, lv_obj_t* obj)
static void statusbar_destructor(TT_UNUSED const lv_obj_class_t* class_p, lv_obj_t* obj) {
auto* statusbar = (Statusbar*)obj;
tt_pubsub_unsubscribe(statusbar_data.pubsub, statusbar->pubsub_subscription);
statusbar_data.pubsub->unsubscribe(statusbar->pubsub_subscription);
}
static void update_icon(lv_obj_t* image, const StatusbarIcon* icon) {
@@ -181,7 +181,7 @@ lv_obj_t* statusbar_create(lv_obj_t* parent) {
obj_set_style_bg_invisible(left_spacer);
lv_obj_set_flex_grow(left_spacer, 1);
statusbar_lock(TtWaitForever);
statusbar_lock(portMAX_DELAY);
for (int i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
auto* image = lv_image_create(obj);
lv_obj_set_size(image, STATUSBAR_ICON_SIZE, STATUSBAR_ICON_SIZE);
@@ -233,7 +233,7 @@ static void statusbar_event(TT_UNUSED const lv_obj_class_t* class_p, lv_event_t*
}
int8_t statusbar_icon_add(const std::string& image) {
statusbar_lock(TtWaitForever);
statusbar_lock();
int8_t result = -1;
for (int8_t i = 0; i < STATUSBAR_ICON_LIMIT; ++i) {
if (!statusbar_data.icons[i].claimed) {
@@ -245,7 +245,7 @@ int8_t statusbar_icon_add(const std::string& image) {
break;
}
}
tt_pubsub_publish(statusbar_data.pubsub, nullptr);
statusbar_data.pubsub->publish(nullptr);
statusbar_unlock();
return result;
}
@@ -257,12 +257,12 @@ int8_t statusbar_icon_add() {
void statusbar_icon_remove(int8_t id) {
TT_LOG_I(TAG, "id %d: remove", id);
tt_check(id >= 0 && id < STATUSBAR_ICON_LIMIT);
statusbar_lock(TtWaitForever);
statusbar_lock();
StatusbarIcon* icon = &statusbar_data.icons[id];
icon->claimed = false;
icon->visible = false;
icon->image = "";
tt_pubsub_publish(statusbar_data.pubsub, nullptr);
statusbar_data.pubsub->publish(nullptr);
statusbar_unlock();
}
@@ -273,7 +273,7 @@ void statusbar_icon_set_image(int8_t id, const std::string& image) {
StatusbarIcon* icon = &statusbar_data.icons[id];
tt_check(icon->claimed);
icon->image = image;
tt_pubsub_publish(statusbar_data.pubsub, nullptr);
statusbar_data.pubsub->publish(nullptr);
statusbar_unlock();
}
}
@@ -285,7 +285,7 @@ void statusbar_icon_set_visibility(int8_t id, bool visible) {
StatusbarIcon* icon = &statusbar_data.icons[id];
tt_check(icon->claimed);
icon->visible = visible;
tt_pubsub_publish(statusbar_data.pubsub, nullptr);
statusbar_data.pubsub->publish(nullptr);
statusbar_unlock();
}
}
+8 -8
View File
@@ -35,7 +35,7 @@ Gui* gui_alloc() {
&guiMain,
nullptr
);
instance->loader_pubsub_subscription = tt_pubsub_subscribe(loader::getPubsub(), &onLoaderMessage, instance);
instance->loader_pubsub_subscription = loader::getPubsub()->subscribe(&onLoaderMessage, instance);
tt_check(lvgl::lock(1000 / portTICK_PERIOD_MS));
instance->keyboardGroup = lv_group_create();
auto* screen_root = lv_scr_act();
@@ -90,7 +90,7 @@ void unlock() {
void requestDraw() {
assert(gui);
ThreadId thread_id = gui->thread->getId();
thread_flags_set(thread_id, GUI_THREAD_FLAG_DRAW);
Thread::setFlags(thread_id, GUI_THREAD_FLAG_DRAW);
}
void showApp(std::shared_ptr<app::AppContext> app) {
@@ -120,19 +120,19 @@ static int32_t guiMain(TT_UNUSED void* p) {
Gui* local_gui = gui;
while (true) {
uint32_t flags = thread_flags_wait(
uint32_t flags = Thread::awaitFlags(
GUI_THREAD_FLAG_ALL,
TtFlagWaitAny,
TtWaitForever
EventFlag::WaitAny,
portMAX_DELAY
);
// Process and dispatch draw call
if (flags & GUI_THREAD_FLAG_DRAW) {
thread_flags_clear(GUI_THREAD_FLAG_DRAW);
Thread::clearFlags(GUI_THREAD_FLAG_DRAW);
redraw(local_gui);
}
if (flags & GUI_THREAD_FLAG_EXIT) {
thread_flags_clear(GUI_THREAD_FLAG_EXIT);
Thread::clearFlags(GUI_THREAD_FLAG_EXIT);
break;
}
}
@@ -159,7 +159,7 @@ public:
lock();
ThreadId thread_id = gui->thread->getId();
thread_flags_set(thread_id, GUI_THREAD_FLAG_EXIT);
Thread::setFlags(thread_id, GUI_THREAD_FLAG_EXIT);
gui->thread->join();
delete gui->thread;
+4 -4
View File
@@ -125,13 +125,13 @@ static void transitionAppToState(std::shared_ptr<app::AppInstance> app, app::Sta
break;
case app::StateShowing: {
LoaderEvent event_showing = { .type = LoaderEventTypeApplicationShowing };
tt_pubsub_publish(loader_singleton->pubsubExternal, &event_showing);
loader_singleton->pubsubExternal->publish(&event_showing);
app->setState(app::StateShowing);
break;
}
case app::StateHiding: {
LoaderEvent event_hiding = { .type = LoaderEventTypeApplicationHiding };
tt_pubsub_publish(loader_singleton->pubsubExternal, &event_hiding);
loader_singleton->pubsubExternal->publish(&event_hiding);
app->setState(app::StateHiding);
break;
}
@@ -174,7 +174,7 @@ static LoaderStatus startAppWithManifestInternal(
transitionAppToState(new_app, app::StateShowing);
LoaderEvent event_external = { .type = LoaderEventTypeApplicationStarted };
tt_pubsub_publish(loader_singleton->pubsubExternal, &event_external);
loader_singleton->pubsubExternal->publish(&event_external);
return LoaderStatus::Ok;
}
@@ -265,7 +265,7 @@ static void stopAppInternal() {
// WARNING: After this point we cannot change the app states from this method directly anymore as we don't have a lock!
LoaderEvent event_external = { .type = LoaderEventTypeApplicationStopped };
tt_pubsub_publish(loader_singleton->pubsubExternal, &event_external);
loader_singleton->pubsubExternal->publish(&event_external);
if (instance_to_resume != nullptr) {
if (result_set) {
+2 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#include "app/AppManifest.h"
#include "Bundle.h"
#include "Pubsub.h"
#include "PubSub.h"
#include "app/AppManifest.h"
#include "service/ServiceManifest.h"
#include <memory>
@@ -41,7 +41,7 @@ bool ScreenshotTask::isFinished() {
void ScreenshotTask::setFinished() {
auto scoped_lockable = mutex.scoped();
scoped_lockable->lock(TtWaitForever);
scoped_lockable->lock();
finished = true;
}
@@ -138,11 +138,11 @@ private:
std::unique_ptr<service::Paths> paths;
void lock() const {
tt_check(mutex.acquire(TtWaitForever) == TtStatusOk);
mutex.lock();
}
void unlock() const {
tt_check(mutex.release() == TtStatusOk);
mutex.unlock();
}
void updateWifiIcon() {