From 81d77d4a70397b9ce3b3d683ec9bfb6fd030d941 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 2 Jan 2013 16:27:01 -0800 Subject: [PATCH] AP_HAL: New semaphore interface * it now looks like a semaphore! --- libraries/AP_HAL/Semaphores.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/libraries/AP_HAL/Semaphores.h b/libraries/AP_HAL/Semaphores.h index 2394d58f18..00e3e335a9 100644 --- a/libraries/AP_HAL/Semaphores.h +++ b/libraries/AP_HAL/Semaphores.h @@ -1,20 +1,18 @@ -#ifndef __AP_HAL_SEMAPHORE_H__ -#define __AP_HAL_SEMAPHORE_H__ +#ifndef __AP_HAL_SEMAPHORES_H__ +#define __AP_HAL_SEMAPHORES_H__ #include +#include + +#define HAL_SEMAPHORE_BLOCK_FOREVER UINT32_MAX + class AP_HAL::Semaphore { public: - // get - to claim ownership of the semaphore - virtual bool get(void* caller) = 0; - - // release - to give up ownership of the semaphore - virtual bool release(void* caller) = 0; - - // call_on_release - returns true if caller successfully added to the - // queue to be called back - virtual bool call_on_release(void* caller, AP_HAL::Proc k) = 0; + virtual bool take(uint32_t timeout_ms) = 0; + virtual bool take_nonblocking() = 0; + virtual bool give() = 0; }; -#endif // __AP_HAL_SEMAPHORE_H__ +#endif // __AP_HAL_SEMAPHORES_H__