Browse Source

AP_HAL_Linux: allow to join threads

master
Lucas De Marchi 8 years ago
parent
commit
992abd170d
  1. 17
      libraries/AP_HAL_Linux/Thread.cpp
  2. 2
      libraries/AP_HAL_Linux/Thread.h

17
libraries/AP_HAL_Linux/Thread.cpp

@ -205,6 +205,23 @@ bool Thread::is_current_thread() @@ -205,6 +205,23 @@ bool Thread::is_current_thread()
return pthread_equal(pthread_self(), _ctx);
}
bool Thread::join()
{
void *ret;
if (_ctx == 0) {
return false;
}
if (pthread_join(_ctx, &ret) != 0 ||
(intptr_t)ret != 0) {
return false;
}
return true;
}
bool PeriodicThread::set_rate(uint32_t rate_hz)
{
if (_started || rate_hz == 0) {

2
libraries/AP_HAL_Linux/Thread.h

@ -47,6 +47,8 @@ public: @@ -47,6 +47,8 @@ public:
virtual bool stop() { return false; }
bool join();
protected:
static void *_run_trampoline(void *arg);

Loading…
Cancel
Save