Skip to content
This repository has been archived by the owner on Aug 19, 2021. It is now read-only.

Commit

Permalink
Merge pull request #17 from ARMmbed/event-callable
Browse files Browse the repository at this point in the history
Add callback operations to event class
  • Loading branch information
geky authored Sep 24, 2016
2 parents 7393a80 + 66f5ee2 commit 5015222
Showing 1 changed file with 156 additions and 0 deletions.
156 changes: 156 additions & 0 deletions Event.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,32 @@ class Event<void()> {
return _event->id;
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void call() {
int id = post();
MBED_ASSERT(id);
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void operator()() {
return call();
}

/** Static thunk for passing as C-style function
*
* @param func Event to call passed as a void pointer
* @param a0..a4 Arguments to pass to the event
*/
static void thunk(void *func) {
return static_cast<Event*>(func)->call();
}

/** Cancels the most recently posted event
*
* Attempts to cancel the most recently posted event. It is safe to call
Expand Down Expand Up @@ -381,6 +407,32 @@ class Event<void(A0)> {
return _event->id;
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0) {
int id = post(a0);
MBED_ASSERT(id);
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void operator()(A0 a0) {
return call(a0);
}

/** Static thunk for passing as C-style function
*
* @param func Event to call passed as a void pointer
* @param a0..a4 Arguments to pass to the event
*/
static void thunk(void *func, A0 a0) {
return static_cast<Event*>(func)->call(a0);
}

/** Cancels the most recently posted event
*
* Attempts to cancel the most recently posted event. It is safe to call
Expand Down Expand Up @@ -574,6 +626,32 @@ class Event<void(A0, A1)> {
return _event->id;
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1) {
int id = post(a0, a1);
MBED_ASSERT(id);
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void operator()(A0 a0, A1 a1) {
return call(a0, a1);
}

/** Static thunk for passing as C-style function
*
* @param func Event to call passed as a void pointer
* @param a0..a4 Arguments to pass to the event
*/
static void thunk(void *func, A0 a0, A1 a1) {
return static_cast<Event*>(func)->call(a0, a1);
}

/** Cancels the most recently posted event
*
* Attempts to cancel the most recently posted event. It is safe to call
Expand Down Expand Up @@ -767,6 +845,32 @@ class Event<void(A0, A1, A2)> {
return _event->id;
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1, A2 a2) {
int id = post(a0, a1, a2);
MBED_ASSERT(id);
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void operator()(A0 a0, A1 a1, A2 a2) {
return call(a0, a1, a2);
}

/** Static thunk for passing as C-style function
*
* @param func Event to call passed as a void pointer
* @param a0..a4 Arguments to pass to the event
*/
static void thunk(void *func, A0 a0, A1 a1, A2 a2) {
return static_cast<Event*>(func)->call(a0, a1, a2);
}

/** Cancels the most recently posted event
*
* Attempts to cancel the most recently posted event. It is safe to call
Expand Down Expand Up @@ -960,6 +1064,32 @@ class Event<void(A0, A1, A2, A3)> {
return _event->id;
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1, A2 a2, A3 a3) {
int id = post(a0, a1, a2, a3);
MBED_ASSERT(id);
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void operator()(A0 a0, A1 a1, A2 a2, A3 a3) {
return call(a0, a1, a2, a3);
}

/** Static thunk for passing as C-style function
*
* @param func Event to call passed as a void pointer
* @param a0..a4 Arguments to pass to the event
*/
static void thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
return static_cast<Event*>(func)->call(a0, a1, a2, a3);
}

/** Cancels the most recently posted event
*
* Attempts to cancel the most recently posted event. It is safe to call
Expand Down Expand Up @@ -1153,6 +1283,32 @@ class Event<void(A0, A1, A2, A3, A4)> {
return _event->id;
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
int id = post(a0, a1, a2, a3, a4);
MBED_ASSERT(id);
}

/** Posts an event onto the underlying event queue, returning void
*
* @param a0..a4 Arguments to pass to the event
*/
void operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
return call(a0, a1, a2, a3, a4);
}

/** Static thunk for passing as C-style function
*
* @param func Event to call passed as a void pointer
* @param a0..a4 Arguments to pass to the event
*/
static void thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
return static_cast<Event*>(func)->call(a0, a1, a2, a3, a4);
}

/** Cancels the most recently posted event
*
* Attempts to cancel the most recently posted event. It is safe to call
Expand Down

0 comments on commit 5015222

Please sign in to comment.