2016-02-17 21:25:25 -04:00
|
|
|
#pragma once
|
2012-11-28 21:53:15 -04:00
|
|
|
|
2015-08-11 03:28:43 -03:00
|
|
|
#include "AP_HAL_Namespace.h"
|
2012-11-28 21:53:15 -04:00
|
|
|
|
2019-02-11 01:39:37 -04:00
|
|
|
#include <AP_Common/AP_Common.h>
|
|
|
|
|
2016-11-03 07:32:09 -03:00
|
|
|
#define HAL_SEMAPHORE_BLOCK_FOREVER 0
|
2012-11-28 21:53:15 -04:00
|
|
|
|
2013-01-02 20:27:01 -04:00
|
|
|
class AP_HAL::Semaphore {
|
|
|
|
public:
|
2013-01-09 05:42:02 -04:00
|
|
|
virtual bool take(uint32_t timeout_ms) WARN_IF_UNUSED = 0 ;
|
|
|
|
virtual bool take_nonblocking() WARN_IF_UNUSED = 0;
|
2018-05-24 20:33:24 -03:00
|
|
|
|
|
|
|
// a varient that blocks forever
|
|
|
|
#pragma GCC diagnostic push
|
|
|
|
#pragma GCC diagnostic ignored "-Wunused-result"
|
|
|
|
virtual void take_blocking() { take(HAL_SEMAPHORE_BLOCK_FOREVER); };
|
|
|
|
#pragma GCC diagnostic pop
|
|
|
|
|
2013-01-02 20:27:01 -04:00
|
|
|
virtual bool give() = 0;
|
2016-11-19 01:47:50 -04:00
|
|
|
virtual ~Semaphore(void) {}
|
2012-11-28 21:53:15 -04:00
|
|
|
};
|