17 #ifndef USER_ALLOCATED_EVENT_H 18 #define USER_ALLOCATED_EVENT_H 20 #include "events/EventQueue.h" 21 #include "platform/mbed_assert.h" 22 #include "platform/mbed_atomic.h" 29 template <
typename F,
typename A>
30 class UserAllocatedEvent;
75 template <
typename F,
typename... ArgTs>
78 typedef EventQueue::context<F, ArgTs...> C;
89 constexpr
UserAllocatedEvent(F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _delay(), _period(-1), _equeue(), _post_ref()
103 constexpr
UserAllocatedEvent(
EventQueue *queue, F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _delay(), _period(-1), _equeue(&queue->_equeue), _post_ref()
191 return post_on(queue);
246 return _post_ref > 0 ? equeue_cancel_user_allocated(_equeue, &_e) :
false;
265 equeue_event_delay(&_e + 1, _delay);
266 equeue_event_period(&_e + 1, _period);
267 equeue_post_user_allocated(_equeue, &EventQueue::function_call<C>, &_e);
277 _equeue = &(queue->_equeue);
279 equeue_event_delay(&_e + 1, _delay);
280 equeue_event_period(&_e + 1, _period);
281 equeue_post_user_allocated(_equeue, &EventQueue::function_call<C>, &_e);
285 static void event_dtor(
void *p)
292 constexpr
static equeue_event get_default_equeue_event()
294 return equeue_event{ 0, 0, 0, NULL, NULL, NULL, 0, -1, &UserAllocatedEvent::event_dtor, NULL };
302 template <
typename T,
typename R>
304 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
309 template <
typename T,
typename R>
311 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
316 template <
typename T,
typename R>
318 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
323 template <
typename T,
typename R>
325 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
330 template <
typename T,
typename R>
332 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
337 template <
typename T,
typename R>
339 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
344 template <
typename T,
typename R>
345 constexpr
UserAllocatedEvent(
const volatile T *obj, R(T::*method)(ArgTs...)
const volatile, ArgTs... args) :
346 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
351 template <
typename T,
typename R>
353 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
358 template <
typename F,
typename... ArgTs>
364 template <
typename T,
typename R,
typename... ArgTs>
370 template <
typename T,
typename R,
typename... ArgTs>
376 template <
typename T,
typename R,
typename... ArgTs>
382 template <
typename T,
typename R,
typename... ArgTs>
398 template <
typename F,
typename... ArgTs>
413 template <
typename T,
typename R,
typename... ArgTs>
428 template <
typename T,
typename R,
typename... ArgTs>
443 template <
typename T,
typename R,
typename... ArgTs>
458 template <
typename T,
typename R,
typename... ArgTs>
void operator()()
Posts an event onto the underlying event queue, returning void.
constexpr UserAllocatedEvent(const T *obj, R(T::*method)(ArgTs...) const, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent(const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent(EventQueue *q, volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent(volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent(T *obj, R(T::*method)(ArgTs...), ArgTs...args)
Create an event.
bool try_call_on(EventQueue *queue)
Posts an event onto the event queue passed as argument,.
void call_on(EventQueue *queue)
Posts an event onto the event queue passed as argument, returning void.
constexpr UserAllocatedEvent(EventQueue *q, const T *obj, R(T::*method)(ArgTs...) const, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent(F f, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent(EventQueue *q, T *obj, R(T::*method)(ArgTs...), ArgTs...args)
Create an event.
bool cancel()
Cancels posted event.
void call()
Posts an event onto the underlying event queue, returning void.
UserAllocatedEvent< F, void(ArgTs...)> make_user_allocated_event(F f, ArgTs...args)
Creates an user allocated event bound to the event queue.
void delay(int delay)
Configure the delay of an event.
void period(int period)
Configure the period of an event.
constexpr UserAllocatedEvent(EventQueue *q, const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs...args)
Create an event.
~UserAllocatedEvent()
Destructor for events.
bool try_call()
Posts an event onto the underlying event queue.
Callback class based on template specialization.
constexpr UserAllocatedEvent(EventQueue *queue, F f, ArgTs...args)
Create an event.
constexpr UserAllocatedEvent< mbed::Callback< void(ArgTs...)>, void(ArgTs...)> make_user_allocated_event(const volatile T *obj, R(T::*method)(ArgTs...args) const volatile, ArgTs...args)
Creates a UserAllocatedEvent object, deducing the target type from the types of arguments.