mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-07-24 15:27:41 +08:00
fix(px4_platform): fix TSAN issues
This commit is contained in:
@@ -40,6 +40,8 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <px4_platform_common/atomic.h>
|
||||
|
||||
namespace px4
|
||||
{
|
||||
|
||||
@@ -48,17 +50,17 @@ class AppState
|
||||
public:
|
||||
~AppState() {}
|
||||
|
||||
AppState() : _exitRequested(false), _isRunning(false) {}
|
||||
AppState() {}
|
||||
|
||||
bool exitRequested() { return _exitRequested; }
|
||||
void requestExit() { _exitRequested = true; }
|
||||
bool exitRequested() { return _exitRequested.load(); }
|
||||
void requestExit() { _exitRequested.store(true); }
|
||||
|
||||
bool isRunning() { return _isRunning; }
|
||||
void setRunning(bool running) { _isRunning = running; }
|
||||
bool isRunning() { return _isRunning.load(); }
|
||||
void setRunning(bool running) { _isRunning.store(running); }
|
||||
|
||||
protected:
|
||||
bool _exitRequested;
|
||||
bool _isRunning;
|
||||
px4::atomic_bool _exitRequested{false};
|
||||
px4::atomic_bool _isRunning{false};
|
||||
private:
|
||||
AppState(const AppState &);
|
||||
const AppState &operator=(const AppState &);
|
||||
|
||||
@@ -40,6 +40,7 @@
|
||||
#include <px4_platform_common/px4_config.h>
|
||||
#include <px4_platform_common/log.h>
|
||||
#include <px4_platform_common/tasks.h>
|
||||
#include <px4_platform_common/time.h>
|
||||
|
||||
#include <nuttx/board.h>
|
||||
#include <nuttx/kthread.h>
|
||||
@@ -91,6 +92,16 @@ int px4_task_delete(int pid)
|
||||
return task_delete(pid);
|
||||
}
|
||||
|
||||
int px4_task_join(int pid)
|
||||
{
|
||||
// Wait for the task to exit by polling whether it still exists
|
||||
while (kill(pid, 0) == 0) {
|
||||
px4_usleep(10000);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
const char *px4_get_taskname(void)
|
||||
{
|
||||
#if CONFIG_TASK_NAME_SIZE > 0 && (defined(__KERNEL__) || defined(CONFIG_BUILD_FLAT))
|
||||
|
||||
Reference in New Issue
Block a user