mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-25 01:41:43 +00:00
Remove priority mutex (#644)
* Removed hal::priority_condition_variable * Replaced uses of priority mutexes with std::mutex and std::recursive_mutex This allowed replacing a use of std::condition_variable_any with std::condition_variable. * Replaced all uses of std::recursive_mutex with std::mutex equivalents
This commit is contained in:
committed by
Peter Johnson
parent
19addb04cf
commit
dd66b23845
@@ -10,12 +10,11 @@
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
|
||||
#include "Commands/Command.h"
|
||||
#include "ErrorBase.h"
|
||||
#include "SmartDashboard/NamedSendable.h"
|
||||
@@ -54,11 +53,11 @@ class Scheduler : public ErrorBase, public NamedSendable {
|
||||
void ProcessCommandAddition(Command* command);
|
||||
|
||||
Command::SubsystemSet m_subsystems;
|
||||
hal::priority_mutex m_buttonsLock;
|
||||
std::mutex m_buttonsLock;
|
||||
typedef std::vector<ButtonScheduler*> ButtonVector;
|
||||
ButtonVector m_buttons;
|
||||
typedef std::vector<Command*> CommandVector;
|
||||
hal::priority_mutex m_additionsLock;
|
||||
std::mutex m_additionsLock;
|
||||
CommandVector m_additions;
|
||||
typedef std::set<Command*> CommandSet;
|
||||
CommandSet m_commands;
|
||||
|
||||
@@ -10,8 +10,7 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <array>
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "DigitalSource.h"
|
||||
|
||||
@@ -52,7 +51,7 @@ class DigitalGlitchFilter : public SensorBase {
|
||||
void DoAdd(DigitalSource* input, int requested_index);
|
||||
|
||||
int m_channelIndex = -1;
|
||||
static hal::priority_mutex m_mutex;
|
||||
static std::mutex m_mutex;
|
||||
static std::array<bool, 3> m_filterAllocated;
|
||||
};
|
||||
|
||||
|
||||
@@ -9,11 +9,11 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
#include <HAL/DriverStation.h>
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "RobotState.h"
|
||||
@@ -116,7 +116,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
std::thread m_dsThread;
|
||||
std::atomic<bool> m_isRunning{false};
|
||||
|
||||
mutable hal::priority_mutex m_joystickDataMutex;
|
||||
mutable std::mutex m_joystickDataMutex;
|
||||
|
||||
// Robot state status variables
|
||||
bool m_userInDisabled = false;
|
||||
@@ -127,7 +127,7 @@ class DriverStation : public SensorBase, public RobotStateInterface {
|
||||
// Control word variables
|
||||
mutable HAL_ControlWord m_controlWordCache;
|
||||
mutable std::chrono::steady_clock::time_point m_lastControlWordUpdate;
|
||||
mutable hal::priority_mutex m_controlWordMutex;
|
||||
mutable std::mutex m_controlWordMutex;
|
||||
|
||||
double m_nextMessageTime = 0;
|
||||
};
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
#include <mutex>
|
||||
|
||||
#include <llvm/StringRef.h>
|
||||
|
||||
#include "Base.h"
|
||||
@@ -114,7 +115,7 @@ class ErrorBase {
|
||||
protected:
|
||||
mutable Error m_error;
|
||||
// TODO: Replace globalError with a global list of all errors.
|
||||
static hal::priority_mutex _globalErrorMutex;
|
||||
static std::mutex _globalErrorMutex;
|
||||
static Error _globalError;
|
||||
};
|
||||
|
||||
|
||||
@@ -7,10 +7,9 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <mutex>
|
||||
#include <set>
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -38,13 +37,13 @@ class MotorSafetyHelper : public ErrorBase {
|
||||
// the FPGA clock value when this motor has expired
|
||||
double m_stopTime;
|
||||
// protect accesses to the state for this object
|
||||
mutable hal::priority_recursive_mutex m_syncMutex;
|
||||
mutable std::mutex m_syncMutex;
|
||||
// the object that is using the helper
|
||||
MotorSafety* m_safeObject;
|
||||
// List of all existing MotorSafetyHelper objects.
|
||||
static std::set<MotorSafetyHelper*> m_helperList;
|
||||
// protect accesses to the list of helpers
|
||||
static hal::priority_recursive_mutex m_listMutex;
|
||||
static std::mutex m_listMutex;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <functional>
|
||||
#include <mutex>
|
||||
#include <utility>
|
||||
|
||||
#include <HAL/Notifier.h>
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
|
||||
@@ -47,9 +47,9 @@ class Notifier : public ErrorBase {
|
||||
static void Notify(uint64_t currentTimeInt, HAL_NotifierHandle handle);
|
||||
|
||||
// used to constrain execution between destructors and callback
|
||||
static hal::priority_mutex m_destructorMutex;
|
||||
static std::mutex m_destructorMutex;
|
||||
// held while updating process information
|
||||
hal::priority_mutex m_processMutex;
|
||||
std::mutex m_processMutex;
|
||||
// HAL handle, atomic for proper destruction
|
||||
std::atomic<HAL_NotifierHandle> m_notifier{0};
|
||||
// address of the handler
|
||||
|
||||
@@ -9,11 +9,10 @@
|
||||
|
||||
#include <atomic>
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <queue>
|
||||
#include <string>
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
|
||||
#include "Base.h"
|
||||
#include "Controller.h"
|
||||
#include "LiveWindow/LiveWindow.h"
|
||||
@@ -148,7 +147,7 @@ class PIDController : public LiveWindowSendable, public PIDInterface {
|
||||
std::queue<double> m_buf;
|
||||
double m_bufTotal = 0;
|
||||
|
||||
mutable hal::priority_recursive_mutex m_mutex;
|
||||
mutable std::mutex m_mutex;
|
||||
|
||||
std::unique_ptr<Notifier> m_controlLoop;
|
||||
Timer m_setpointTimer;
|
||||
|
||||
@@ -10,11 +10,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
|
||||
#include "ErrorBase.h"
|
||||
|
||||
namespace frc {
|
||||
@@ -44,9 +43,9 @@ class Resource : public ErrorBase {
|
||||
|
||||
private:
|
||||
std::vector<bool> m_isAllocated;
|
||||
hal::priority_recursive_mutex m_allocateLock;
|
||||
std::mutex m_allocateMutex;
|
||||
|
||||
static hal::priority_recursive_mutex m_createLock;
|
||||
static std::mutex m_createMutex;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <HAL/cpp/priority_mutex.h>
|
||||
#include <mutex>
|
||||
|
||||
#include "Base.h"
|
||||
|
||||
@@ -52,7 +52,7 @@ class Timer {
|
||||
double m_startTime = 0.0;
|
||||
double m_accumulatedTime = 0.0;
|
||||
bool m_running = false;
|
||||
mutable hal::priority_mutex m_mutex;
|
||||
mutable std::mutex m_mutex;
|
||||
};
|
||||
|
||||
} // namespace frc
|
||||
|
||||
Reference in New Issue
Block a user