mirror of
https://git.intern.spaceteamaachen.de/ALPAKA/rtos2-utils.git
synced 2025-08-06 19:17:34 +00:00
Add semaphore based signal implementation
This commit is contained in:
29
src/os2/signal.cpp
Normal file
29
src/os2/signal.cpp
Normal file
@@ -0,0 +1,29 @@
|
||||
#include <sta/os2/signal.hpp>
|
||||
|
||||
|
||||
namespace sta
|
||||
{
|
||||
Os2Signal::Os2Signal(osSemaphoreId_t * semaphore)
|
||||
: semaphore_{semaphore}
|
||||
{}
|
||||
|
||||
void Os2Signal::notify()
|
||||
{
|
||||
osSemaphoreRelease(*semaphore_);
|
||||
}
|
||||
|
||||
bool Os2Signal::peek()
|
||||
{
|
||||
return (osSemaphoreGetCount(*semaphore_) != 0);
|
||||
}
|
||||
|
||||
bool Os2Signal::test()
|
||||
{
|
||||
return (osSemaphoreAcquire(*semaphore_, 0) == osOK);
|
||||
}
|
||||
|
||||
void Os2Signal::wait()
|
||||
{
|
||||
osSemaphoreAcquire(*semaphore_, osWaitForever);
|
||||
}
|
||||
} // namespace sta
|
Reference in New Issue
Block a user