| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
#pragma once |
| 7 |
|
| 8 |
#ifdef _AVR_ |
| 9 |
#error there is no implementation for waiter.h on AVR platforms |
| 10 |
#else |
| 11 |
|
| 12 |
#include "hal/event.h" |
| 13 |
|
| 14 |
namespace rp{ namespace hal{ |
| 15 |
|
| 16 |
template<typename ResultT> |
| 17 |
class Waiter : public Event |
| 18 |
{ |
| 19 |
public: |
| 20 |
Waiter() |
| 21 |
: Event() |
| 22 |
{ |
| 23 |
} |
| 24 |
|
| 25 |
~Waiter() |
| 26 |
{} |
| 27 |
|
| 28 |
ResultT waitForResult() |
| 29 |
{ |
| 30 |
wait(); |
| 31 |
return result; |
| 32 |
} |
| 33 |
|
| 34 |
void setResult(ResultT _result) |
| 35 |
{ |
| 36 |
this->result = _result; |
| 37 |
set(); |
| 38 |
} |
| 39 |
|
| 40 |
volatile ResultT result; |
| 41 |
}; |
| 42 |
}} |
| 43 |
|
| 44 |
#endif |