Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix race condition in System::ClockBuilder #618

Merged
merged 2 commits into from
Mar 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ All notable changes to this project are documented in this file.
- Return an invalid `PolyDriverDescriptor` if `description` is not found in `constructMultipleAnalogSensorsRemapper()` (https://github.com/ami-iit/bipedal-locomotion-framework/pull/569)
- Fix compatibility with OpenCV 4.7.0 (https://github.com/ami-iit/bipedal-locomotion-framework/pull/589)
- Fix `attachRemappedRemoteControlBoard` in `YarpSensorBridge` when the `RemoteControlBoard` is not the first polydriver in the polydriverlist (https://github.com/ami-iit/bipedal-locomotion-framework/pull/608)
- Fix race condition in System::ClockBuilder (https://github.com/ami-iit/bipedal-locomotion-framework/pull/618)

## [0.11.1] - 2022-12-19
### Fix
Expand Down
7 changes: 4 additions & 3 deletions src/System/include/BipedalLocomotion/System/Clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#ifndef BIPEDAL_LOCOMOTION_SYSTEM_CLOCK_H
#define BIPEDAL_LOCOMOTION_SYSTEM_CLOCK_H

#include <atomic>
#include <memory>

#include <BipedalLocomotion/System/IClock.h>
Expand All @@ -30,9 +31,9 @@ class ClockBuilder
* Pointer to factory used to build the clock
*/
inline static std::shared_ptr<ClockFactory> m_factory{std::make_shared<StdClockFactory>()};
inline static bool m_clockAlreadyCalledOnce{false}; /**< True if the clock() has been already
called once. If True it will not be
possible to set a new Factory */
inline static std::atomic<bool> m_clockAlreadyCalledOnce{false}; /**< True if the clock() has been already
called once. If True it will not be
possible to set a new Factory */

public:
/**
Expand Down