Mistake on this page?
Report an issue in GitHub or email us
Public Member Functions
UserAllocatedEvent< F, void(ArgTs...)> Class Template Reference

UserAllocatedEvent. More...

#include <UserAllocatedEvent.h>

Public Member Functions

constexpr UserAllocatedEvent (F f, ArgTs...args)
 Create an event. More...
 
constexpr UserAllocatedEvent (EventQueue *queue, F f, ArgTs...args)
 Create an event. More...
 
 ~UserAllocatedEvent ()
 Destructor for events. More...
 
void call ()
 Posts an event onto the underlying event queue, returning void. More...
 
void call_on (EventQueue *queue)
 Posts an event onto the event queue passed as argument, returning void. More...
 
bool try_call ()
 Posts an event onto the underlying event queue. More...
 
bool try_call_on (EventQueue *queue)
 Posts an event onto the event queue passed as argument,. More...
 
void operator() ()
 Posts an event onto the underlying event queue, returning void. More...
 
void delay (int delay)
 Configure the delay of an event. More...
 
void period (int period)
 Configure the period of an event. More...
 
bool cancel ()
 Cancels posted event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (T *obj, R(T::*method)(ArgTs...), ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (EventQueue *q, T *obj, R(T::*method)(ArgTs...), ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (const T *obj, R(T::*method)(ArgTs...) const, ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (EventQueue *q, const T *obj, R(T::*method)(ArgTs...) const, ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (EventQueue *q, volatile T *obj, R(T::*method)(ArgTs...) volatile, ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs...args)
 Create an event. More...
 
template<typename T , typename R >
constexpr UserAllocatedEvent (EventQueue *q, const volatile T *obj, R(T::*method)(ArgTs...) const volatile, ArgTs...args)
 Create an event. More...
 

Detailed Description

template<typename F, typename... ArgTs>
class events::UserAllocatedEvent< F, void(ArgTs...)>

UserAllocatedEvent.

Representation of an static event for fine-grain dispatch control.

UserAllocatedEvent provides mechanism for event posting and dispatching without utilization of queue internal memory. It embeds all underlying event data and doesn't require any memory allocation while posting and dispatching. All of these makes it cannot fail due to memory exhaustion while posting

Usage:

#include "mbed.h"
void handler(int data) { ... }
class Device {
public:
void handler(int data) { ... }
};
Device dev;
// queue with not internal storage for dynamic events
// accepts only user allocated events
static EventQueue queue(0);
// Create events
static auto e1 = make_user_allocated_event(&dev, Device::handler, 2);
static auto e2 = queue.make_user_allocated_event(handler, 3);
int main()
{
e1.call_on(&queue);
e2.call();
queue.dispatch(1);
}

Definition at line 76 of file UserAllocatedEvent.h.

Constructor & Destructor Documentation

constexpr UserAllocatedEvent ( f,
ArgTs...  args 
)

Create an event.

Constructs an event. The specified callback acts as the target for the event and is executed in the context of the event queue's dispatch loop once posted.

Parameters
fFunction to execute when the event is dispatched
argsArguments to bind to the callback

Definition at line 89 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( EventQueue queue,
f,
ArgTs...  args 
)

Create an event.

Constructs an event. The specified callback acts as the target for the event and is executed in the context of the event queue's dispatch loop once posted.

Parameters
queueEvent queue to dispatch on
fFunction to execute when the event is dispatched
argsArguments to bind to the callback

Definition at line 103 of file UserAllocatedEvent.h.

Destructor for events.

Definition at line 112 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( T *  obj,
R(T::*)(ArgTs...)  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 303 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( EventQueue q,
T *  obj,
R(T::*)(ArgTs...)  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 310 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( const T *  obj,
R(T::*)(ArgTs...) const  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 317 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( EventQueue q,
const T *  obj,
R(T::*)(ArgTs...) const  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 324 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( volatile T *  obj,
R(T::*)(ArgTs...) volatile  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 331 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( EventQueue q,
volatile T *  obj,
R(T::*)(ArgTs...) volatile  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 338 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( const volatile T *  obj,
R(T::*)(ArgTs...) const volatile  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 345 of file UserAllocatedEvent.h.

constexpr UserAllocatedEvent ( EventQueue q,
const volatile T *  obj,
R(T::*)(ArgTs...) const volatile  method,
ArgTs...  args 
)

Create an event.

See also
UserAllocatedEvent::UserAllocatedEvent

Definition at line 352 of file UserAllocatedEvent.h.

Member Function Documentation

void call ( )

Posts an event onto the underlying event queue, returning void.

The event is posted to the underlying queue and is executed in the context of the event queue's dispatch loop.

This call cannot fail due queue memory exhaustion because it doesn't allocate any memory

The post function is IRQ safe and can act as a mechanism for moving events out of IRQ contexts.

Definition at line 130 of file UserAllocatedEvent.h.

void call_on ( EventQueue queue)

Posts an event onto the event queue passed as argument, returning void.

The event is posted to the event queue passed as argument and is executed in the context of the event queue's dispatch loop.

This call cannot fail due queue memory exhaustion because it doesn't allocate any memory

The post function is IRQ safe and can act as a mechanism for moving events out of IRQ contexts.

Parameters
queueEvent queue to dispatch on. Will replace earlier bound EventQueue.

Definition at line 152 of file UserAllocatedEvent.h.

bool cancel ( )

Cancels posted event.

Attempts to cancel posted event. It is not safe to call cancel after an event has already been dispatched.

The cancel function is IRQ safe.

If called while the event queue's dispatch loop is active, the cancel function does not guarantee that the event will not execute after it returns, as the event may have already begun executing.

Returns
true if event was successfully cancelled

Definition at line 244 of file UserAllocatedEvent.h.

void delay ( int  delay)

Configure the delay of an event.

Parameters
delayMillisecond delay before dispatching the event

Definition at line 215 of file UserAllocatedEvent.h.

void operator() ( )

Posts an event onto the underlying event queue, returning void.

The event is posted to the underlying queue and is executed in the context of the event queue's dispatch loop.

This call cannot fail due queue memory exhaustion because it doesn't allocate any memory

The post function is IRQ safe and can act as a mechanism for moving events out of IRQ contexts.

Definition at line 206 of file UserAllocatedEvent.h.

void period ( int  period)

Configure the period of an event.

Parameters
periodMillisecond period for repeatedly dispatching an event

Definition at line 225 of file UserAllocatedEvent.h.

bool try_call ( )

Posts an event onto the underlying event queue.

The event is posted to the event queue passed as argument and is executed in the context of the event queue's dispatch loop.

This call cannot fail due queue memory exhaustion because it doesn't allocate any memory

Returns
False if the event was already posted true otherwise

Definition at line 171 of file UserAllocatedEvent.h.

bool try_call_on ( EventQueue queue)

Posts an event onto the event queue passed as argument,.

The event is posted to the underlying queue and is executed in the context of the event queue's dispatch loop.

This call cannot fail due queue memory exhaustion because it doesn't allocate any memory

Parameters
queueEvent queue to dispatch on. Will replace earlier bound EventQueue.
Returns
False if the event was already posted true otherwise

Definition at line 189 of file UserAllocatedEvent.h.

Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.