mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-22 08:13:34 +08:00
uORBDeviceNode: use px4::atomic instead of volatile for _generation
_generation is read in a multi-threaded context w/o locking.
This commit is contained in:
@@ -39,6 +39,7 @@
|
||||
#include <lib/cdev/CDev.hpp>
|
||||
|
||||
#include <containers/List.hpp>
|
||||
#include <px4_platform_common/atomic.h>
|
||||
|
||||
namespace uORB
|
||||
{
|
||||
@@ -185,7 +186,7 @@ public:
|
||||
|
||||
uint32_t lost_message_count() const { return _lost_messages; }
|
||||
|
||||
unsigned published_message_count() const { return _generation; }
|
||||
unsigned published_message_count() const { return _generation.load(); }
|
||||
|
||||
const orb_metadata *get_meta() const { return _meta; }
|
||||
|
||||
@@ -267,7 +268,7 @@ private:
|
||||
const uint8_t _instance; /**< orb multi instance identifier */
|
||||
uint8_t *_data{nullptr}; /**< allocated object buffer */
|
||||
hrt_abstime _last_update{0}; /**< time the object was last updated */
|
||||
volatile unsigned _generation{0}; /**< object generation count */
|
||||
px4::atomic<unsigned> _generation{0}; /**< object generation count */
|
||||
List<uORB::SubscriptionCallback *> _callbacks;
|
||||
uint8_t _priority; /**< priority of the topic */
|
||||
bool _published{false}; /**< has ever data been published */
|
||||
|
||||
Reference in New Issue
Block a user