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...), _equeue(), _post_ref()
103 constexpr
UserAllocatedEvent(
EventQueue *queue, F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _equeue(&queue->_equeue), _post_ref()
191 return post_on(queue);
218 equeue_event_delay(&_e + 1, delay);
228 equeue_event_period(&_e + 1, period);
246 return equeue_cancel_user_allocated(_equeue, &_e);
263 equeue_post_user_allocated(_equeue, &EventQueue::function_call<C>, &_e);
272 _equeue = &(queue->_equeue);
274 equeue_post_user_allocated(_equeue, &EventQueue::function_call<C>, &_e);
278 static void event_dtor(
void *p)
285 constexpr
static equeue_event get_default_equeue_event()
287 return equeue_event{ 0, 0, 0, NULL, NULL, NULL, 0, -1, &UserAllocatedEvent::event_dtor, NULL };
295 template <
typename T,
typename R>
297 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
302 template <
typename T,
typename R>
304 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
309 template <
typename T,
typename R>
311 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
316 template <
typename T,
typename R>
318 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
323 template <
typename T,
typename R>
325 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
330 template <
typename T,
typename R>
332 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
337 template <
typename T,
typename R>
338 constexpr
UserAllocatedEvent(
const volatile T *obj, R(T::*method)(ArgTs...)
const volatile, ArgTs... args) :
339 UserAllocatedEvent(
mbed::
callback(obj, method), args...) { }
344 template <
typename T,
typename R>
346 UserAllocatedEvent(q,
mbed::
callback(obj, method), args...) { }
351 template <
typename F,
typename... ArgTs>
357 template <
typename T,
typename R,
typename... ArgTs>
363 template <
typename T,
typename R,
typename... ArgTs>
369 template <
typename T,
typename R,
typename... ArgTs>
375 template <
typename T,
typename R,
typename... ArgTs>
391 template <
typename F,
typename... ArgTs>
406 template <
typename T,
typename R,
typename... ArgTs>
421 template <
typename T,
typename R,
typename... ArgTs>
436 template <
typename T,
typename R,
typename... ArgTs>
451 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.