2016-02-17 21:25:26 -04:00
|
|
|
#pragma once
|
2013-09-22 03:01:24 -03:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include <AP_HAL/AP_HAL_Boards.h>
|
2018-08-07 03:39:42 -03:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <AP_HAL/AP_HAL_Macros.h>
|
|
|
|
#include <AP_HAL/Semaphores.h>
|
|
|
|
#include <pthread.h>
|
2013-09-22 03:01:24 -03:00
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
namespace Linux {
|
|
|
|
|
|
|
|
class Semaphore : public AP_HAL::Semaphore {
|
2013-09-22 03:01:24 -03:00
|
|
|
public:
|
2018-08-19 22:09:05 -03:00
|
|
|
Semaphore();
|
2019-02-21 19:08:12 -04:00
|
|
|
bool give() override;
|
|
|
|
bool take(uint32_t timeout_ms) override;
|
|
|
|
bool take_nonblocking() override;
|
2018-08-19 22:09:05 -03:00
|
|
|
protected:
|
2013-09-28 18:49:30 -03:00
|
|
|
pthread_mutex_t _lock;
|
2013-09-22 03:01:24 -03:00
|
|
|
};
|
2016-07-29 16:14:02 -03:00
|
|
|
|
2018-08-19 22:09:05 -03:00
|
|
|
class Semaphore_Recursive : public Semaphore {
|
|
|
|
public:
|
|
|
|
Semaphore_Recursive();
|
|
|
|
};
|
|
|
|
|
2016-07-29 16:14:02 -03:00
|
|
|
}
|