Split off RecursiveMutex from Mutex (#437)
* Split off RecursiveMutex from Mutex * Fix * Code quality
This commit is contained in:
committed by
GitHub
parent
f48654d3dc
commit
3fc2ff8bc6
@@ -4,7 +4,7 @@
|
||||
#include "GpsConfiguration.h"
|
||||
#include "Satellites.h"
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Thread.h>
|
||||
|
||||
#include <minmea.h>
|
||||
@@ -47,7 +47,7 @@ private:
|
||||
};
|
||||
|
||||
const GpsConfiguration configuration;
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::unique_ptr<Thread> _Nullable thread;
|
||||
bool threadInterrupted = false;
|
||||
std::vector<GgaSubscription> ggaSubscriptions;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/RtosCompat.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
#include <minmea.h>
|
||||
|
||||
@@ -30,7 +30,7 @@ private:
|
||||
bool inUse = false;
|
||||
};
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::array<SatelliteRecord, recordCount> records;
|
||||
uint16_t recycleTimeSeconds;
|
||||
uint16_t recentTimeSeconds;
|
||||
|
||||
@@ -4,14 +4,13 @@
|
||||
|
||||
#include "SdCardDevice.h"
|
||||
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/hal/Device.h>
|
||||
#include <Tactility/hal/spi/Spi.h>
|
||||
|
||||
#include <sd_protocol_types.h>
|
||||
#include <soc/gpio_num.h>
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include <Tactility/hal/Device.h>
|
||||
#include <hal/spi_types.h>
|
||||
#include <soc/gpio_num.h>
|
||||
|
||||
namespace tt::hal::sdcard {
|
||||
|
||||
@@ -20,7 +19,7 @@ namespace tt::hal::sdcard {
|
||||
*/
|
||||
class SdmmcDevice final : public SdCardDevice {
|
||||
|
||||
std::shared_ptr<Mutex> mutex = std::make_shared<Mutex>(Mutex::Type::Recursive);
|
||||
std::shared_ptr<RecursiveMutex> mutex = std::make_shared<RecursiveMutex>();
|
||||
|
||||
public:
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
#ifdef ESP_PLATFORM
|
||||
|
||||
#include <esp_http_server.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
|
||||
namespace tt::network {
|
||||
@@ -33,7 +33,7 @@ private:
|
||||
|
||||
std::vector<httpd_uri_t> handlers;
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
httpd_handle_t server = nullptr;
|
||||
|
||||
bool startInternal();
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "Tactility/Mutex.h"
|
||||
#include "Tactility/RecursiveMutex.h"
|
||||
#include "Tactility/PubSub.h"
|
||||
#include "Tactility/hal/gps/GpsDevice.h"
|
||||
#include "Tactility/service/Service.h"
|
||||
@@ -20,7 +21,7 @@ class GpsService final : public Service {
|
||||
minmea_sentence_rmc rmcRecord;
|
||||
TickType_t rmcTime = 0;
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
Mutex stateMutex;
|
||||
std::vector<GpsDeviceRecord> deviceRecords;
|
||||
std::shared_ptr<PubSub<State>> statePubSub = std::make_shared<PubSub<State>>();
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <Tactility/Bundle.h>
|
||||
#include <Tactility/DispatcherThread.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/Service.h>
|
||||
|
||||
#include <memory>
|
||||
@@ -26,7 +27,7 @@ public:
|
||||
private:
|
||||
|
||||
std::shared_ptr<PubSub<Event>> pubsubExternal = std::make_shared<PubSub<Event>>();
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::vector<std::shared_ptr<app::AppInstance>> appStack;
|
||||
app::LaunchId nextLaunchId = 0;
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ enum class State {
|
||||
*/
|
||||
class AppInstance : public AppContext {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Normal);
|
||||
Mutex mutex;
|
||||
const std::shared_ptr<AppManifest> manifest;
|
||||
State state = State::Initial;
|
||||
LaunchId launchId;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -20,7 +20,7 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::vector<dirent> dir_entries;
|
||||
std::string current_path;
|
||||
std::string selected_child_entry;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
@@ -10,7 +10,7 @@ namespace tt::app::fileselection {
|
||||
|
||||
class State final {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::vector<dirent> dir_entries;
|
||||
std::string current_path;
|
||||
std::string selected_child_entry;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/service/wifi/Wifi.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
namespace tt::app::wifimanage {
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace tt::app::wifimanage {
|
||||
*/
|
||||
class State final {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
bool scanning = false;
|
||||
bool scannedAfterRadioOn = false;
|
||||
service::wifi::RadioState radioState;
|
||||
|
||||
@@ -10,7 +10,7 @@ namespace tt::service {
|
||||
|
||||
class ServiceInstance final : public ServiceContext {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Normal);
|
||||
Mutex mutex;
|
||||
std::shared_ptr<const ServiceManifest> manifest;
|
||||
std::shared_ptr<Service> service;
|
||||
State state = State::Stopped;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include <Tactility/service/Service.h>
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
#include <esp_event.h>
|
||||
#include <esp_http_server.h>
|
||||
@@ -13,7 +13,7 @@ namespace tt::service::development {
|
||||
|
||||
class DevelopmentService final : public Service {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::string deviceResponse;
|
||||
network::HttpServer httpServer = network::HttpServer(
|
||||
6666,
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
#include <Tactility/service/Service.h>
|
||||
#include <Tactility/service/espnow/EspNow.h>
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
#include <functional>
|
||||
|
||||
@@ -27,7 +27,7 @@ class EspNowService final : public Service {
|
||||
bool success;
|
||||
};
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::vector<ReceiverSubscriptionData> subscriptions;
|
||||
ReceiverSubscription lastSubscriptionId = 0;
|
||||
bool enabled = false;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <Tactility/app/AppContext.h>
|
||||
#include <Tactility/MessageQueue.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/service/Service.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
@@ -21,7 +21,7 @@ class GuiService final : public Service {
|
||||
|
||||
// Thread and lock
|
||||
Thread* thread = nullptr;
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
PubSub<loader::LoaderService::Event>::SubscriptionHandle loader_pubsub_subscription = nullptr;
|
||||
|
||||
// Layers and Canvas
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace tt::service::memorychecker {
|
||||
*/
|
||||
class MemoryCheckerService final : public Service {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
Mutex mutex;
|
||||
Timer timer = Timer(Timer::Type::Periodic, [this] { onTimerUpdate(); });
|
||||
|
||||
// LVGL Statusbar icon
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/Thread.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
namespace tt::service::screenshot {
|
||||
|
||||
@@ -22,7 +22,7 @@ class ScreenshotTask {
|
||||
};
|
||||
|
||||
Thread* thread = nullptr;
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
bool interrupted = false;
|
||||
bool finished = false;
|
||||
ScreenshotTaskWork work;
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace tt::app {
|
||||
typedef std::unordered_map<std::string, std::shared_ptr<AppManifest>> AppManifestMap;
|
||||
|
||||
static AppManifestMap app_manifest_map;
|
||||
static Mutex hash_mutex(Mutex::Type::Normal);
|
||||
static Mutex hash_mutex;
|
||||
|
||||
void addAppManifest(const AppManifest& manifest) {
|
||||
TT_LOG_I(TAG, "Registering manifest %s", manifest.appId.c_str());
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
@@ -24,7 +25,7 @@ class I2cScannerApp final : public App {
|
||||
static constexpr auto* STOP_SCAN_TEXT = "Stop scan";
|
||||
|
||||
// Core
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::unique_ptr<Timer> scanTimer = nullptr;
|
||||
// State
|
||||
ScanState scanState = ScanStateInitial;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/app/timezone/TimeZone.h>
|
||||
#include <Tactility/app/localesettings/TextResources.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
@@ -26,7 +27,7 @@ extern const AppManifest manifest;
|
||||
|
||||
class LocaleSettingsApp final : public App {
|
||||
tt::i18n::TextResources textResources = tt::i18n::TextResources(TEXT_RESOURCE_PATH);
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
lv_obj_t* timeZoneLabel = nullptr;
|
||||
lv_obj_t* regionLabel = nullptr;
|
||||
lv_obj_t* languageDropdown = nullptr;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#include <Tactility/Assets.h>
|
||||
#include <Tactility/app/AppManifest.h>
|
||||
#include <Tactility/lvgl/Toolbar.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/loader/Loader.h>
|
||||
#include <Tactility/settings/Time.h>
|
||||
|
||||
@@ -14,7 +15,7 @@ extern const AppManifest manifest;
|
||||
|
||||
class TimeDateSettingsApp final : public App {
|
||||
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
|
||||
static void onTimeFormatChanged(lv_event_t* event) {
|
||||
auto* widget = lv_event_get_target_obj(event);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
#include "Tactility/hal/Device.h"
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <algorithm>
|
||||
|
||||
namespace tt::hal {
|
||||
|
||||
std::vector<std::shared_ptr<Device>> devices;
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
static Device::Id nextId = 0;
|
||||
|
||||
#define TAG "devices"
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#include "Tactility/hal/spi/Spi.h"
|
||||
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
|
||||
namespace tt::hal::spi {
|
||||
|
||||
@@ -24,7 +24,7 @@ bool init(const std::vector<Configuration>& configurations) {
|
||||
if (configuration.lock != nullptr) {
|
||||
data.lock = configuration.lock;
|
||||
} else {
|
||||
data.lock = std::make_shared<Mutex>(Mutex::Type::Recursive);
|
||||
data.lock = std::make_shared<RecursiveMutex>();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,23 +1,22 @@
|
||||
#define LV_USE_PRIVATE_API 1 // For actual lv_obj_t declaration
|
||||
|
||||
#include "Tactility/lvgl/Statusbar.h"
|
||||
|
||||
#include "Tactility/lvgl/Style.h"
|
||||
#include "Tactility/lvgl/LvglSync.h"
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/lvgl/Statusbar.h>
|
||||
#include <Tactility/lvgl/Style.h>
|
||||
#include <Tactility/lvgl/LvglSync.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/TactilityCore.h>
|
||||
#include <Tactility/Timer.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/settings/Time.h>
|
||||
#include <Tactility/Timer.h>
|
||||
|
||||
#include <lvgl.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
|
||||
namespace tt::lvgl {
|
||||
|
||||
#define TAG "statusbar"
|
||||
constexpr auto TAG = "statusbar";
|
||||
|
||||
static void onUpdateTime();
|
||||
|
||||
@@ -28,7 +27,7 @@ struct StatusbarIcon {
|
||||
};
|
||||
|
||||
struct StatusbarData {
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
std::shared_ptr<PubSub<void*>> pubsub = std::make_shared<PubSub<void*>>();
|
||||
StatusbarIcon icons[STATUSBAR_ICON_LIMIT] = {};
|
||||
Timer* time_update_timer = new Timer(Timer::Type::Once, [] { onUpdateTime(); });
|
||||
|
||||
@@ -17,8 +17,8 @@ typedef std::unordered_map<std::string, std::shared_ptr<ServiceInstance>> Servic
|
||||
static ManifestMap service_manifest_map;
|
||||
static ServiceInstanceMap service_instance_map;
|
||||
|
||||
static Mutex manifest_mutex(Mutex::Type::Normal);
|
||||
static Mutex instance_mutex(Mutex::Type::Normal);
|
||||
static Mutex manifest_mutex;
|
||||
static Mutex instance_mutex;
|
||||
|
||||
void addService(std::shared_ptr<const ServiceManifest> manifest, bool autoStart) {
|
||||
assert(manifest != nullptr);
|
||||
|
||||
@@ -9,6 +9,7 @@
|
||||
#include <Tactility/EventFlag.h>
|
||||
#include <Tactility/Tactility.h>
|
||||
#include <Tactility/kernel/SystemEvents.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/ServiceContext.h>
|
||||
#include <Tactility/service/wifi/WifiGlobals.h>
|
||||
#include <Tactility/service/wifi/WifiSettings.h>
|
||||
@@ -48,8 +49,8 @@ class Wifi {
|
||||
public:
|
||||
|
||||
/** @brief Locking mechanism for modifying the Wifi instance */
|
||||
Mutex radioMutex = Mutex(Mutex::Type::Recursive);
|
||||
Mutex dataMutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex radioMutex;
|
||||
RecursiveMutex dataMutex;
|
||||
std::unique_ptr<Timer> autoConnectTimer;
|
||||
/** @brief The public event bus */
|
||||
std::shared_ptr<PubSub<WifiEvent>> pubsub = std::make_shared<PubSub<WifiEvent>>();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
#include <Tactility/Check.h>
|
||||
#include <Tactility/Log.h>
|
||||
#include <Tactility/Mutex.h>
|
||||
#include <Tactility/PubSub.h>
|
||||
#include <Tactility/RecursiveMutex.h>
|
||||
#include <Tactility/service/Service.h>
|
||||
#include <Tactility/service/ServiceManifest.h>
|
||||
|
||||
@@ -15,7 +15,7 @@ constexpr auto* TAG = "Wifi";
|
||||
|
||||
struct Wifi {
|
||||
/** @brief Locking mechanism for modifying the Wifi instance */
|
||||
Mutex mutex = Mutex(Mutex::Type::Recursive);
|
||||
RecursiveMutex mutex;
|
||||
/** @brief The public event bus */
|
||||
std::shared_ptr<PubSub<WifiEvent>> pubsub = std::make_shared<PubSub<WifiEvent>>();
|
||||
/** @brief The internal message queue */
|
||||
|
||||
Reference in New Issue
Block a user