mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-19 00:41:43 +00:00
Use wpi::mutex instead of std::mutex. (#730)
This uses a priority-aware mutex on Linux platforms. Fixes #729.
This commit is contained in:
@@ -83,7 +83,7 @@ double Timer::Get() const {
|
||||
double result;
|
||||
double currentTime = GetFPGATimestamp();
|
||||
|
||||
std::lock_guard<std::mutex> sync(m_mutex);
|
||||
std::lock_guard<wpi::mutex> sync(m_mutex);
|
||||
if (m_running) {
|
||||
// If the current time is before the start time, then the FPGA clock
|
||||
// rolled over. Compensate by adding the ~71 minutes that it takes
|
||||
@@ -107,7 +107,7 @@ double Timer::Get() const {
|
||||
* now.
|
||||
*/
|
||||
void Timer::Reset() {
|
||||
std::lock_guard<std::mutex> sync(m_mutex);
|
||||
std::lock_guard<wpi::mutex> sync(m_mutex);
|
||||
m_accumulatedTime = 0;
|
||||
m_startTime = GetFPGATimestamp();
|
||||
}
|
||||
@@ -119,7 +119,7 @@ void Timer::Reset() {
|
||||
* relative to the system clock.
|
||||
*/
|
||||
void Timer::Start() {
|
||||
std::lock_guard<std::mutex> sync(m_mutex);
|
||||
std::lock_guard<wpi::mutex> sync(m_mutex);
|
||||
if (!m_running) {
|
||||
m_startTime = GetFPGATimestamp();
|
||||
m_running = true;
|
||||
@@ -136,7 +136,7 @@ void Timer::Start() {
|
||||
void Timer::Stop() {
|
||||
double temp = Get();
|
||||
|
||||
std::lock_guard<std::mutex> sync(m_mutex);
|
||||
std::lock_guard<wpi::mutex> sync(m_mutex);
|
||||
if (m_running) {
|
||||
m_accumulatedTime = temp;
|
||||
m_running = false;
|
||||
@@ -153,7 +153,7 @@ void Timer::Stop() {
|
||||
*/
|
||||
bool Timer::HasPeriodPassed(double period) {
|
||||
if (Get() > period) {
|
||||
std::lock_guard<std::mutex> sync(m_mutex);
|
||||
std::lock_guard<wpi::mutex> sync(m_mutex);
|
||||
// Advance the start time by the period.
|
||||
m_startTime += period;
|
||||
// Don't set it to the current time... we want to avoid drift.
|
||||
|
||||
Reference in New Issue
Block a user