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:
Beat Küng
2019-11-23 10:10:05 -05:00
committed by Daniel Agar
parent d648d52ac3
commit 0f6f795aca
2 changed files with 13 additions and 10 deletions
+3 -2
View File
@@ -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 */