Rtos API example

Committer:
marcozecchini
Date:
Sat Feb 23 12:13:36 2019 +0000
Revision:
0:9fca2b23d0ba
final commit

Who changed what in which revision?

UserRevisionLine numberNew contents of line
marcozecchini 0:9fca2b23d0ba 1 /* events
marcozecchini 0:9fca2b23d0ba 2 * Copyright (c) 2016 ARM Limited
marcozecchini 0:9fca2b23d0ba 3 *
marcozecchini 0:9fca2b23d0ba 4 * Licensed under the Apache License, Version 2.0 (the "License");
marcozecchini 0:9fca2b23d0ba 5 * you may not use this file except in compliance with the License.
marcozecchini 0:9fca2b23d0ba 6 * You may obtain a copy of the License at
marcozecchini 0:9fca2b23d0ba 7 *
marcozecchini 0:9fca2b23d0ba 8 * http://www.apache.org/licenses/LICENSE-2.0
marcozecchini 0:9fca2b23d0ba 9 *
marcozecchini 0:9fca2b23d0ba 10 * Unless required by applicable law or agreed to in writing, software
marcozecchini 0:9fca2b23d0ba 11 * distributed under the License is distributed on an "AS IS" BASIS,
marcozecchini 0:9fca2b23d0ba 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
marcozecchini 0:9fca2b23d0ba 13 * See the License for the specific language governing permissions and
marcozecchini 0:9fca2b23d0ba 14 * limitations under the License.
marcozecchini 0:9fca2b23d0ba 15 */
marcozecchini 0:9fca2b23d0ba 16 #ifndef EVENT_H
marcozecchini 0:9fca2b23d0ba 17 #define EVENT_H
marcozecchini 0:9fca2b23d0ba 18
marcozecchini 0:9fca2b23d0ba 19 #include "events/EventQueue.h"
marcozecchini 0:9fca2b23d0ba 20 #include "platform/mbed_assert.h"
marcozecchini 0:9fca2b23d0ba 21
marcozecchini 0:9fca2b23d0ba 22 namespace events {
marcozecchini 0:9fca2b23d0ba 23 /** \addtogroup events */
marcozecchini 0:9fca2b23d0ba 24
marcozecchini 0:9fca2b23d0ba 25 /** Event
marcozecchini 0:9fca2b23d0ba 26 *
marcozecchini 0:9fca2b23d0ba 27 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 28 * @ingroup events
marcozecchini 0:9fca2b23d0ba 29 */
marcozecchini 0:9fca2b23d0ba 30 template <typename F>
marcozecchini 0:9fca2b23d0ba 31 class Event;
marcozecchini 0:9fca2b23d0ba 32
marcozecchini 0:9fca2b23d0ba 33 /** Event
marcozecchini 0:9fca2b23d0ba 34 *
marcozecchini 0:9fca2b23d0ba 35 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 36 * @ingroup events
marcozecchini 0:9fca2b23d0ba 37 */
marcozecchini 0:9fca2b23d0ba 38 template <>
marcozecchini 0:9fca2b23d0ba 39 class Event<void()> {
marcozecchini 0:9fca2b23d0ba 40 public:
marcozecchini 0:9fca2b23d0ba 41 /** Create an event
marcozecchini 0:9fca2b23d0ba 42 *
marcozecchini 0:9fca2b23d0ba 43 * Constructs an event bound to the specified event queue. The specified
marcozecchini 0:9fca2b23d0ba 44 * callback acts as the target for the event and is executed in the
marcozecchini 0:9fca2b23d0ba 45 * context of the event queue's dispatch loop once posted.
marcozecchini 0:9fca2b23d0ba 46 *
marcozecchini 0:9fca2b23d0ba 47 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 48 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 49 */
marcozecchini 0:9fca2b23d0ba 50 template <typename F>
marcozecchini 0:9fca2b23d0ba 51 Event(EventQueue *q, F f) {
marcozecchini 0:9fca2b23d0ba 52 _event = static_cast<struct event *>(
marcozecchini 0:9fca2b23d0ba 53 equeue_alloc(&q->_equeue, sizeof(struct event) + sizeof(F)));
marcozecchini 0:9fca2b23d0ba 54
marcozecchini 0:9fca2b23d0ba 55 if (_event) {
marcozecchini 0:9fca2b23d0ba 56 _event->equeue = &q->_equeue;
marcozecchini 0:9fca2b23d0ba 57 _event->id = 0;
marcozecchini 0:9fca2b23d0ba 58 _event->delay = 0;
marcozecchini 0:9fca2b23d0ba 59 _event->period = -1;
marcozecchini 0:9fca2b23d0ba 60
marcozecchini 0:9fca2b23d0ba 61 _event->post = &Event::event_post<F>;
marcozecchini 0:9fca2b23d0ba 62 _event->dtor = &Event::event_dtor<F>;
marcozecchini 0:9fca2b23d0ba 63
marcozecchini 0:9fca2b23d0ba 64 new (_event+1) F(f);
marcozecchini 0:9fca2b23d0ba 65
marcozecchini 0:9fca2b23d0ba 66 _event->ref = 1;
marcozecchini 0:9fca2b23d0ba 67 }
marcozecchini 0:9fca2b23d0ba 68 }
marcozecchini 0:9fca2b23d0ba 69
marcozecchini 0:9fca2b23d0ba 70 /** Copy constructor for events
marcozecchini 0:9fca2b23d0ba 71 */
marcozecchini 0:9fca2b23d0ba 72 Event(const Event &e) {
marcozecchini 0:9fca2b23d0ba 73 _event = 0;
marcozecchini 0:9fca2b23d0ba 74 if (e._event) {
marcozecchini 0:9fca2b23d0ba 75 _event = e._event;
marcozecchini 0:9fca2b23d0ba 76 _event->ref += 1;
marcozecchini 0:9fca2b23d0ba 77 }
marcozecchini 0:9fca2b23d0ba 78 }
marcozecchini 0:9fca2b23d0ba 79
marcozecchini 0:9fca2b23d0ba 80 /** Assignment operator for events
marcozecchini 0:9fca2b23d0ba 81 */
marcozecchini 0:9fca2b23d0ba 82 Event &operator=(const Event &that) {
marcozecchini 0:9fca2b23d0ba 83 if (this != &that) {
marcozecchini 0:9fca2b23d0ba 84 this->~Event();
marcozecchini 0:9fca2b23d0ba 85 new (this) Event(that);
marcozecchini 0:9fca2b23d0ba 86 }
marcozecchini 0:9fca2b23d0ba 87
marcozecchini 0:9fca2b23d0ba 88 return *this;
marcozecchini 0:9fca2b23d0ba 89 }
marcozecchini 0:9fca2b23d0ba 90
marcozecchini 0:9fca2b23d0ba 91 /** Destructor for events
marcozecchini 0:9fca2b23d0ba 92 */
marcozecchini 0:9fca2b23d0ba 93 ~Event() {
marcozecchini 0:9fca2b23d0ba 94 if (_event) {
marcozecchini 0:9fca2b23d0ba 95 _event->ref -= 1;
marcozecchini 0:9fca2b23d0ba 96 if (_event->ref == 0) {
marcozecchini 0:9fca2b23d0ba 97 _event->dtor(_event);
marcozecchini 0:9fca2b23d0ba 98 equeue_dealloc(_event->equeue, _event);
marcozecchini 0:9fca2b23d0ba 99 }
marcozecchini 0:9fca2b23d0ba 100 }
marcozecchini 0:9fca2b23d0ba 101 }
marcozecchini 0:9fca2b23d0ba 102
marcozecchini 0:9fca2b23d0ba 103 /** Configure the delay of an event
marcozecchini 0:9fca2b23d0ba 104 *
marcozecchini 0:9fca2b23d0ba 105 * @param delay Millisecond delay before dispatching the event
marcozecchini 0:9fca2b23d0ba 106 */
marcozecchini 0:9fca2b23d0ba 107 void delay(int delay) {
marcozecchini 0:9fca2b23d0ba 108 if (_event) {
marcozecchini 0:9fca2b23d0ba 109 _event->delay = delay;
marcozecchini 0:9fca2b23d0ba 110 }
marcozecchini 0:9fca2b23d0ba 111 }
marcozecchini 0:9fca2b23d0ba 112
marcozecchini 0:9fca2b23d0ba 113 /** Configure the period of an event
marcozecchini 0:9fca2b23d0ba 114 *
marcozecchini 0:9fca2b23d0ba 115 * @param period Millisecond period for repeatedly dispatching an event
marcozecchini 0:9fca2b23d0ba 116 */
marcozecchini 0:9fca2b23d0ba 117 void period(int period) {
marcozecchini 0:9fca2b23d0ba 118 if (_event) {
marcozecchini 0:9fca2b23d0ba 119 _event->period = period;
marcozecchini 0:9fca2b23d0ba 120 }
marcozecchini 0:9fca2b23d0ba 121 }
marcozecchini 0:9fca2b23d0ba 122
marcozecchini 0:9fca2b23d0ba 123 /** Posts an event onto the underlying event queue
marcozecchini 0:9fca2b23d0ba 124 *
marcozecchini 0:9fca2b23d0ba 125 * The event is posted to the underlying queue and is executed in the
marcozecchini 0:9fca2b23d0ba 126 * context of the event queue's dispatch loop.
marcozecchini 0:9fca2b23d0ba 127 *
marcozecchini 0:9fca2b23d0ba 128 * The post function is irq safe and can act as a mechanism for moving
marcozecchini 0:9fca2b23d0ba 129 * events out of irq contexts.
marcozecchini 0:9fca2b23d0ba 130 *
marcozecchini 0:9fca2b23d0ba 131 * @return A unique id that represents the posted event and can
marcozecchini 0:9fca2b23d0ba 132 * be passed to EventQueue::cancel, or an id of 0 if
marcozecchini 0:9fca2b23d0ba 133 * there is not enough memory to allocate the event.
marcozecchini 0:9fca2b23d0ba 134 */
marcozecchini 0:9fca2b23d0ba 135 int post() const {
marcozecchini 0:9fca2b23d0ba 136 if (!_event) {
marcozecchini 0:9fca2b23d0ba 137 return 0;
marcozecchini 0:9fca2b23d0ba 138 }
marcozecchini 0:9fca2b23d0ba 139
marcozecchini 0:9fca2b23d0ba 140 _event->id = _event->post(_event);
marcozecchini 0:9fca2b23d0ba 141 return _event->id;
marcozecchini 0:9fca2b23d0ba 142 }
marcozecchini 0:9fca2b23d0ba 143
marcozecchini 0:9fca2b23d0ba 144 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 145 *
marcozecchini 0:9fca2b23d0ba 146 */
marcozecchini 0:9fca2b23d0ba 147 void call() const {
marcozecchini 0:9fca2b23d0ba 148 MBED_UNUSED int id = post();
marcozecchini 0:9fca2b23d0ba 149 MBED_ASSERT(id);
marcozecchini 0:9fca2b23d0ba 150 }
marcozecchini 0:9fca2b23d0ba 151
marcozecchini 0:9fca2b23d0ba 152 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 153 *
marcozecchini 0:9fca2b23d0ba 154 */
marcozecchini 0:9fca2b23d0ba 155 void operator()() const {
marcozecchini 0:9fca2b23d0ba 156 return call();
marcozecchini 0:9fca2b23d0ba 157 }
marcozecchini 0:9fca2b23d0ba 158
marcozecchini 0:9fca2b23d0ba 159 /** Static thunk for passing as C-style function
marcozecchini 0:9fca2b23d0ba 160 *
marcozecchini 0:9fca2b23d0ba 161 * @param func Event to call passed as a void pointer
marcozecchini 0:9fca2b23d0ba 162 */
marcozecchini 0:9fca2b23d0ba 163 static void thunk(void *func) {
marcozecchini 0:9fca2b23d0ba 164 return static_cast<Event*>(func)->call();
marcozecchini 0:9fca2b23d0ba 165 }
marcozecchini 0:9fca2b23d0ba 166
marcozecchini 0:9fca2b23d0ba 167 /** Cancels the most recently posted event
marcozecchini 0:9fca2b23d0ba 168 *
marcozecchini 0:9fca2b23d0ba 169 * Attempts to cancel the most recently posted event. It is safe to call
marcozecchini 0:9fca2b23d0ba 170 * cancel after an event has already been dispatched.
marcozecchini 0:9fca2b23d0ba 171 *
marcozecchini 0:9fca2b23d0ba 172 * The cancel function is irq safe.
marcozecchini 0:9fca2b23d0ba 173 *
marcozecchini 0:9fca2b23d0ba 174 * If called while the event queue's dispatch loop is active, the cancel
marcozecchini 0:9fca2b23d0ba 175 * function does not garuntee that the event will not execute after it
marcozecchini 0:9fca2b23d0ba 176 * returns, as the event may have already begun executing.
marcozecchini 0:9fca2b23d0ba 177 */
marcozecchini 0:9fca2b23d0ba 178 void cancel() const {
marcozecchini 0:9fca2b23d0ba 179 if (_event) {
marcozecchini 0:9fca2b23d0ba 180 equeue_cancel(_event->equeue, _event->id);
marcozecchini 0:9fca2b23d0ba 181 }
marcozecchini 0:9fca2b23d0ba 182 }
marcozecchini 0:9fca2b23d0ba 183
marcozecchini 0:9fca2b23d0ba 184 private:
marcozecchini 0:9fca2b23d0ba 185 struct event {
marcozecchini 0:9fca2b23d0ba 186 unsigned ref;
marcozecchini 0:9fca2b23d0ba 187 equeue_t *equeue;
marcozecchini 0:9fca2b23d0ba 188 int id;
marcozecchini 0:9fca2b23d0ba 189
marcozecchini 0:9fca2b23d0ba 190 int delay;
marcozecchini 0:9fca2b23d0ba 191 int period;
marcozecchini 0:9fca2b23d0ba 192
marcozecchini 0:9fca2b23d0ba 193 int (*post)(struct event *);
marcozecchini 0:9fca2b23d0ba 194 void (*dtor)(struct event *);
marcozecchini 0:9fca2b23d0ba 195
marcozecchini 0:9fca2b23d0ba 196 // F follows
marcozecchini 0:9fca2b23d0ba 197 } *_event;
marcozecchini 0:9fca2b23d0ba 198
marcozecchini 0:9fca2b23d0ba 199 // Event attributes
marcozecchini 0:9fca2b23d0ba 200 template <typename F>
marcozecchini 0:9fca2b23d0ba 201 static int event_post(struct event *e) {
marcozecchini 0:9fca2b23d0ba 202 typedef EventQueue::context00<F> C;
marcozecchini 0:9fca2b23d0ba 203 void *p = equeue_alloc(e->equeue, sizeof(C));
marcozecchini 0:9fca2b23d0ba 204 if (!p) {
marcozecchini 0:9fca2b23d0ba 205 return 0;
marcozecchini 0:9fca2b23d0ba 206 }
marcozecchini 0:9fca2b23d0ba 207
marcozecchini 0:9fca2b23d0ba 208 new (p) C(*(F*)(e + 1));
marcozecchini 0:9fca2b23d0ba 209 equeue_event_delay(p, e->delay);
marcozecchini 0:9fca2b23d0ba 210 equeue_event_period(p, e->period);
marcozecchini 0:9fca2b23d0ba 211 equeue_event_dtor(p, &EventQueue::function_dtor<C>);
marcozecchini 0:9fca2b23d0ba 212 return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
marcozecchini 0:9fca2b23d0ba 213 }
marcozecchini 0:9fca2b23d0ba 214
marcozecchini 0:9fca2b23d0ba 215 template <typename F>
marcozecchini 0:9fca2b23d0ba 216 static void event_dtor(struct event *e) {
marcozecchini 0:9fca2b23d0ba 217 ((F*)(e + 1))->~F();
marcozecchini 0:9fca2b23d0ba 218 }
marcozecchini 0:9fca2b23d0ba 219
marcozecchini 0:9fca2b23d0ba 220 public:
marcozecchini 0:9fca2b23d0ba 221 /** Create an event
marcozecchini 0:9fca2b23d0ba 222 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 223 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 224 * @param c0 Argument to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 225 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 226 * memory pool. Must be type-compatible with b0, the
marcozecchini 0:9fca2b23d0ba 227 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 228 */
marcozecchini 0:9fca2b23d0ba 229 template <typename F, typename C0>
marcozecchini 0:9fca2b23d0ba 230 Event(EventQueue *q, F f, C0 c0) {
marcozecchini 0:9fca2b23d0ba 231 new (this) Event(q, EventQueue::context10<F, C0>(f, c0));
marcozecchini 0:9fca2b23d0ba 232 }
marcozecchini 0:9fca2b23d0ba 233
marcozecchini 0:9fca2b23d0ba 234 /** Create an event
marcozecchini 0:9fca2b23d0ba 235 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 236 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 237 * @param c0,c1 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 238 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 239 * memory pool. Must be type-compatible with b0..b1, the
marcozecchini 0:9fca2b23d0ba 240 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 241 */
marcozecchini 0:9fca2b23d0ba 242 template <typename F, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 243 Event(EventQueue *q, F f, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 244 new (this) Event(q, EventQueue::context20<F, C0, C1>(f, c0, c1));
marcozecchini 0:9fca2b23d0ba 245 }
marcozecchini 0:9fca2b23d0ba 246
marcozecchini 0:9fca2b23d0ba 247 /** Create an event
marcozecchini 0:9fca2b23d0ba 248 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 249 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 250 * @param c0,c1,c2 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 251 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 252 * memory pool. Must be type-compatible with b0..b2, the
marcozecchini 0:9fca2b23d0ba 253 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 254 */
marcozecchini 0:9fca2b23d0ba 255 template <typename F, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 256 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 257 new (this) Event(q, EventQueue::context30<F, C0, C1, C2>(f, c0, c1, c2));
marcozecchini 0:9fca2b23d0ba 258 }
marcozecchini 0:9fca2b23d0ba 259
marcozecchini 0:9fca2b23d0ba 260 /** Create an event
marcozecchini 0:9fca2b23d0ba 261 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 262 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 263 * @param c0,c1,c2,c3 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 264 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 265 * memory pool. Must be type-compatible with b0..b3, the
marcozecchini 0:9fca2b23d0ba 266 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 267 */
marcozecchini 0:9fca2b23d0ba 268 template <typename F, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 269 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 270 new (this) Event(q, EventQueue::context40<F, C0, C1, C2, C3>(f, c0, c1, c2, c3));
marcozecchini 0:9fca2b23d0ba 271 }
marcozecchini 0:9fca2b23d0ba 272
marcozecchini 0:9fca2b23d0ba 273 /** Create an event
marcozecchini 0:9fca2b23d0ba 274 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 275 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 276 * @param c0,c1,c2,c3,c4 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 277 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 278 * memory pool. Must be type-compatible with b0..b4, the
marcozecchini 0:9fca2b23d0ba 279 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 280 */
marcozecchini 0:9fca2b23d0ba 281 template <typename F, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 282 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 283 new (this) Event(q, EventQueue::context50<F, C0, C1, C2, C3, C4>(f, c0, c1, c2, c3, c4));
marcozecchini 0:9fca2b23d0ba 284 }
marcozecchini 0:9fca2b23d0ba 285
marcozecchini 0:9fca2b23d0ba 286 /** Create an event
marcozecchini 0:9fca2b23d0ba 287 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 288 */
marcozecchini 0:9fca2b23d0ba 289 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 290 Event(EventQueue *q, T *obj, R (T::*method)(B0), B0 b0) {
marcozecchini 0:9fca2b23d0ba 291 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 292 }
marcozecchini 0:9fca2b23d0ba 293
marcozecchini 0:9fca2b23d0ba 294 /** Create an event
marcozecchini 0:9fca2b23d0ba 295 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 296 */
marcozecchini 0:9fca2b23d0ba 297 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 298 Event(EventQueue *q, const T *obj, R (T::*method)(B0) const, B0 b0) {
marcozecchini 0:9fca2b23d0ba 299 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 300 }
marcozecchini 0:9fca2b23d0ba 301
marcozecchini 0:9fca2b23d0ba 302 /** Create an event
marcozecchini 0:9fca2b23d0ba 303 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 304 */
marcozecchini 0:9fca2b23d0ba 305 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 306 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0) volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 307 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 308 }
marcozecchini 0:9fca2b23d0ba 309
marcozecchini 0:9fca2b23d0ba 310 /** Create an event
marcozecchini 0:9fca2b23d0ba 311 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 312 */
marcozecchini 0:9fca2b23d0ba 313 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 314 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0) const volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 315 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 316 }
marcozecchini 0:9fca2b23d0ba 317
marcozecchini 0:9fca2b23d0ba 318 /** Create an event
marcozecchini 0:9fca2b23d0ba 319 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 320 */
marcozecchini 0:9fca2b23d0ba 321 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 322 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1), B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 323 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 324 }
marcozecchini 0:9fca2b23d0ba 325
marcozecchini 0:9fca2b23d0ba 326 /** Create an event
marcozecchini 0:9fca2b23d0ba 327 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 328 */
marcozecchini 0:9fca2b23d0ba 329 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 330 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1) const, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 331 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 332 }
marcozecchini 0:9fca2b23d0ba 333
marcozecchini 0:9fca2b23d0ba 334 /** Create an event
marcozecchini 0:9fca2b23d0ba 335 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 336 */
marcozecchini 0:9fca2b23d0ba 337 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 338 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1) volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 339 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 340 }
marcozecchini 0:9fca2b23d0ba 341
marcozecchini 0:9fca2b23d0ba 342 /** Create an event
marcozecchini 0:9fca2b23d0ba 343 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 344 */
marcozecchini 0:9fca2b23d0ba 345 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 346 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1) const volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 347 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 348 }
marcozecchini 0:9fca2b23d0ba 349
marcozecchini 0:9fca2b23d0ba 350 /** Create an event
marcozecchini 0:9fca2b23d0ba 351 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 352 */
marcozecchini 0:9fca2b23d0ba 353 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 354 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2), B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 355 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 356 }
marcozecchini 0:9fca2b23d0ba 357
marcozecchini 0:9fca2b23d0ba 358 /** Create an event
marcozecchini 0:9fca2b23d0ba 359 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 360 */
marcozecchini 0:9fca2b23d0ba 361 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 362 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2) const, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 363 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 364 }
marcozecchini 0:9fca2b23d0ba 365
marcozecchini 0:9fca2b23d0ba 366 /** Create an event
marcozecchini 0:9fca2b23d0ba 367 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 368 */
marcozecchini 0:9fca2b23d0ba 369 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 370 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2) volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 371 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 372 }
marcozecchini 0:9fca2b23d0ba 373
marcozecchini 0:9fca2b23d0ba 374 /** Create an event
marcozecchini 0:9fca2b23d0ba 375 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 376 */
marcozecchini 0:9fca2b23d0ba 377 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 378 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2) const volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 379 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 380 }
marcozecchini 0:9fca2b23d0ba 381
marcozecchini 0:9fca2b23d0ba 382 /** Create an event
marcozecchini 0:9fca2b23d0ba 383 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 384 */
marcozecchini 0:9fca2b23d0ba 385 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 386 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3), B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 387 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 388 }
marcozecchini 0:9fca2b23d0ba 389
marcozecchini 0:9fca2b23d0ba 390 /** Create an event
marcozecchini 0:9fca2b23d0ba 391 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 392 */
marcozecchini 0:9fca2b23d0ba 393 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 394 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3) const, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 395 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 396 }
marcozecchini 0:9fca2b23d0ba 397
marcozecchini 0:9fca2b23d0ba 398 /** Create an event
marcozecchini 0:9fca2b23d0ba 399 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 400 */
marcozecchini 0:9fca2b23d0ba 401 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 402 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3) volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 403 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 404 }
marcozecchini 0:9fca2b23d0ba 405
marcozecchini 0:9fca2b23d0ba 406 /** Create an event
marcozecchini 0:9fca2b23d0ba 407 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 408 */
marcozecchini 0:9fca2b23d0ba 409 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 410 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3) const volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 411 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 412 }
marcozecchini 0:9fca2b23d0ba 413
marcozecchini 0:9fca2b23d0ba 414 /** Create an event
marcozecchini 0:9fca2b23d0ba 415 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 416 */
marcozecchini 0:9fca2b23d0ba 417 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 418 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, B4), B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 419 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 420 }
marcozecchini 0:9fca2b23d0ba 421
marcozecchini 0:9fca2b23d0ba 422 /** Create an event
marcozecchini 0:9fca2b23d0ba 423 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 424 */
marcozecchini 0:9fca2b23d0ba 425 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 426 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, B4) const, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 427 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 428 }
marcozecchini 0:9fca2b23d0ba 429
marcozecchini 0:9fca2b23d0ba 430 /** Create an event
marcozecchini 0:9fca2b23d0ba 431 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 432 */
marcozecchini 0:9fca2b23d0ba 433 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 434 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4) volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 435 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 436 }
marcozecchini 0:9fca2b23d0ba 437
marcozecchini 0:9fca2b23d0ba 438 /** Create an event
marcozecchini 0:9fca2b23d0ba 439 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 440 */
marcozecchini 0:9fca2b23d0ba 441 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 442 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4) const volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 443 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 444 }
marcozecchini 0:9fca2b23d0ba 445 };
marcozecchini 0:9fca2b23d0ba 446
marcozecchini 0:9fca2b23d0ba 447 /** Event
marcozecchini 0:9fca2b23d0ba 448 *
marcozecchini 0:9fca2b23d0ba 449 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 450 * @ingroup events
marcozecchini 0:9fca2b23d0ba 451 */
marcozecchini 0:9fca2b23d0ba 452 template <typename A0>
marcozecchini 0:9fca2b23d0ba 453 class Event<void(A0)> {
marcozecchini 0:9fca2b23d0ba 454 public:
marcozecchini 0:9fca2b23d0ba 455 /** Create an event
marcozecchini 0:9fca2b23d0ba 456 *
marcozecchini 0:9fca2b23d0ba 457 * Constructs an event bound to the specified event queue. The specified
marcozecchini 0:9fca2b23d0ba 458 * callback acts as the target for the event and is executed in the
marcozecchini 0:9fca2b23d0ba 459 * context of the event queue's dispatch loop once posted.
marcozecchini 0:9fca2b23d0ba 460 *
marcozecchini 0:9fca2b23d0ba 461 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 462 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 463 */
marcozecchini 0:9fca2b23d0ba 464 template <typename F>
marcozecchini 0:9fca2b23d0ba 465 Event(EventQueue *q, F f) {
marcozecchini 0:9fca2b23d0ba 466 _event = static_cast<struct event *>(
marcozecchini 0:9fca2b23d0ba 467 equeue_alloc(&q->_equeue, sizeof(struct event) + sizeof(F)));
marcozecchini 0:9fca2b23d0ba 468
marcozecchini 0:9fca2b23d0ba 469 if (_event) {
marcozecchini 0:9fca2b23d0ba 470 _event->equeue = &q->_equeue;
marcozecchini 0:9fca2b23d0ba 471 _event->id = 0;
marcozecchini 0:9fca2b23d0ba 472 _event->delay = 0;
marcozecchini 0:9fca2b23d0ba 473 _event->period = -1;
marcozecchini 0:9fca2b23d0ba 474
marcozecchini 0:9fca2b23d0ba 475 _event->post = &Event::event_post<F>;
marcozecchini 0:9fca2b23d0ba 476 _event->dtor = &Event::event_dtor<F>;
marcozecchini 0:9fca2b23d0ba 477
marcozecchini 0:9fca2b23d0ba 478 new (_event+1) F(f);
marcozecchini 0:9fca2b23d0ba 479
marcozecchini 0:9fca2b23d0ba 480 _event->ref = 1;
marcozecchini 0:9fca2b23d0ba 481 }
marcozecchini 0:9fca2b23d0ba 482 }
marcozecchini 0:9fca2b23d0ba 483
marcozecchini 0:9fca2b23d0ba 484 /** Copy constructor for events
marcozecchini 0:9fca2b23d0ba 485 */
marcozecchini 0:9fca2b23d0ba 486 Event(const Event &e) {
marcozecchini 0:9fca2b23d0ba 487 _event = 0;
marcozecchini 0:9fca2b23d0ba 488 if (e._event) {
marcozecchini 0:9fca2b23d0ba 489 _event = e._event;
marcozecchini 0:9fca2b23d0ba 490 _event->ref += 1;
marcozecchini 0:9fca2b23d0ba 491 }
marcozecchini 0:9fca2b23d0ba 492 }
marcozecchini 0:9fca2b23d0ba 493
marcozecchini 0:9fca2b23d0ba 494 /** Assignment operator for events
marcozecchini 0:9fca2b23d0ba 495 */
marcozecchini 0:9fca2b23d0ba 496 Event &operator=(const Event &that) {
marcozecchini 0:9fca2b23d0ba 497 if (this != &that) {
marcozecchini 0:9fca2b23d0ba 498 this->~Event();
marcozecchini 0:9fca2b23d0ba 499 new (this) Event(that);
marcozecchini 0:9fca2b23d0ba 500 }
marcozecchini 0:9fca2b23d0ba 501
marcozecchini 0:9fca2b23d0ba 502 return *this;
marcozecchini 0:9fca2b23d0ba 503 }
marcozecchini 0:9fca2b23d0ba 504
marcozecchini 0:9fca2b23d0ba 505 /** Destructor for events
marcozecchini 0:9fca2b23d0ba 506 */
marcozecchini 0:9fca2b23d0ba 507 ~Event() {
marcozecchini 0:9fca2b23d0ba 508 if (_event) {
marcozecchini 0:9fca2b23d0ba 509 _event->ref -= 1;
marcozecchini 0:9fca2b23d0ba 510 if (_event->ref == 0) {
marcozecchini 0:9fca2b23d0ba 511 _event->dtor(_event);
marcozecchini 0:9fca2b23d0ba 512 equeue_dealloc(_event->equeue, _event);
marcozecchini 0:9fca2b23d0ba 513 }
marcozecchini 0:9fca2b23d0ba 514 }
marcozecchini 0:9fca2b23d0ba 515 }
marcozecchini 0:9fca2b23d0ba 516
marcozecchini 0:9fca2b23d0ba 517 /** Configure the delay of an event
marcozecchini 0:9fca2b23d0ba 518 *
marcozecchini 0:9fca2b23d0ba 519 * @param delay Millisecond delay before dispatching the event
marcozecchini 0:9fca2b23d0ba 520 */
marcozecchini 0:9fca2b23d0ba 521 void delay(int delay) {
marcozecchini 0:9fca2b23d0ba 522 if (_event) {
marcozecchini 0:9fca2b23d0ba 523 _event->delay = delay;
marcozecchini 0:9fca2b23d0ba 524 }
marcozecchini 0:9fca2b23d0ba 525 }
marcozecchini 0:9fca2b23d0ba 526
marcozecchini 0:9fca2b23d0ba 527 /** Configure the period of an event
marcozecchini 0:9fca2b23d0ba 528 *
marcozecchini 0:9fca2b23d0ba 529 * @param period Millisecond period for repeatedly dispatching an event
marcozecchini 0:9fca2b23d0ba 530 */
marcozecchini 0:9fca2b23d0ba 531 void period(int period) {
marcozecchini 0:9fca2b23d0ba 532 if (_event) {
marcozecchini 0:9fca2b23d0ba 533 _event->period = period;
marcozecchini 0:9fca2b23d0ba 534 }
marcozecchini 0:9fca2b23d0ba 535 }
marcozecchini 0:9fca2b23d0ba 536
marcozecchini 0:9fca2b23d0ba 537 /** Posts an event onto the underlying event queue
marcozecchini 0:9fca2b23d0ba 538 *
marcozecchini 0:9fca2b23d0ba 539 * The event is posted to the underlying queue and is executed in the
marcozecchini 0:9fca2b23d0ba 540 * context of the event queue's dispatch loop.
marcozecchini 0:9fca2b23d0ba 541 *
marcozecchini 0:9fca2b23d0ba 542 * The post function is irq safe and can act as a mechanism for moving
marcozecchini 0:9fca2b23d0ba 543 * events out of irq contexts.
marcozecchini 0:9fca2b23d0ba 544 *
marcozecchini 0:9fca2b23d0ba 545 * @param a0 Argument to pass to the event
marcozecchini 0:9fca2b23d0ba 546 * @return A unique id that represents the posted event and can
marcozecchini 0:9fca2b23d0ba 547 * be passed to EventQueue::cancel, or an id of 0 if
marcozecchini 0:9fca2b23d0ba 548 * there is not enough memory to allocate the event.
marcozecchini 0:9fca2b23d0ba 549 */
marcozecchini 0:9fca2b23d0ba 550 int post(A0 a0) const {
marcozecchini 0:9fca2b23d0ba 551 if (!_event) {
marcozecchini 0:9fca2b23d0ba 552 return 0;
marcozecchini 0:9fca2b23d0ba 553 }
marcozecchini 0:9fca2b23d0ba 554
marcozecchini 0:9fca2b23d0ba 555 _event->id = _event->post(_event, a0);
marcozecchini 0:9fca2b23d0ba 556 return _event->id;
marcozecchini 0:9fca2b23d0ba 557 }
marcozecchini 0:9fca2b23d0ba 558
marcozecchini 0:9fca2b23d0ba 559 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 560 *
marcozecchini 0:9fca2b23d0ba 561 * @param a0 Argument to pass to the event
marcozecchini 0:9fca2b23d0ba 562 */
marcozecchini 0:9fca2b23d0ba 563 void call(A0 a0) const {
marcozecchini 0:9fca2b23d0ba 564 MBED_UNUSED int id = post(a0);
marcozecchini 0:9fca2b23d0ba 565 MBED_ASSERT(id);
marcozecchini 0:9fca2b23d0ba 566 }
marcozecchini 0:9fca2b23d0ba 567
marcozecchini 0:9fca2b23d0ba 568 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 569 *
marcozecchini 0:9fca2b23d0ba 570 * @param a0 Argument to pass to the event
marcozecchini 0:9fca2b23d0ba 571 */
marcozecchini 0:9fca2b23d0ba 572 void operator()(A0 a0) const {
marcozecchini 0:9fca2b23d0ba 573 return call(a0);
marcozecchini 0:9fca2b23d0ba 574 }
marcozecchini 0:9fca2b23d0ba 575
marcozecchini 0:9fca2b23d0ba 576 /** Static thunk for passing as C-style function
marcozecchini 0:9fca2b23d0ba 577 *
marcozecchini 0:9fca2b23d0ba 578 * @param func Event to call passed as a void pointer
marcozecchini 0:9fca2b23d0ba 579 * @param a0 Argument to pass to the event
marcozecchini 0:9fca2b23d0ba 580 */
marcozecchini 0:9fca2b23d0ba 581 static void thunk(void *func, A0 a0) {
marcozecchini 0:9fca2b23d0ba 582 return static_cast<Event*>(func)->call(a0);
marcozecchini 0:9fca2b23d0ba 583 }
marcozecchini 0:9fca2b23d0ba 584
marcozecchini 0:9fca2b23d0ba 585 /** Cancels the most recently posted event
marcozecchini 0:9fca2b23d0ba 586 *
marcozecchini 0:9fca2b23d0ba 587 * Attempts to cancel the most recently posted event. It is safe to call
marcozecchini 0:9fca2b23d0ba 588 * cancel after an event has already been dispatched.
marcozecchini 0:9fca2b23d0ba 589 *
marcozecchini 0:9fca2b23d0ba 590 * The cancel function is irq safe.
marcozecchini 0:9fca2b23d0ba 591 *
marcozecchini 0:9fca2b23d0ba 592 * If called while the event queue's dispatch loop is active, the cancel
marcozecchini 0:9fca2b23d0ba 593 * function does not garuntee that the event will not execute after it
marcozecchini 0:9fca2b23d0ba 594 * returns, as the event may have already begun executing.
marcozecchini 0:9fca2b23d0ba 595 */
marcozecchini 0:9fca2b23d0ba 596 void cancel() const {
marcozecchini 0:9fca2b23d0ba 597 if (_event) {
marcozecchini 0:9fca2b23d0ba 598 equeue_cancel(_event->equeue, _event->id);
marcozecchini 0:9fca2b23d0ba 599 }
marcozecchini 0:9fca2b23d0ba 600 }
marcozecchini 0:9fca2b23d0ba 601
marcozecchini 0:9fca2b23d0ba 602 private:
marcozecchini 0:9fca2b23d0ba 603 struct event {
marcozecchini 0:9fca2b23d0ba 604 unsigned ref;
marcozecchini 0:9fca2b23d0ba 605 equeue_t *equeue;
marcozecchini 0:9fca2b23d0ba 606 int id;
marcozecchini 0:9fca2b23d0ba 607
marcozecchini 0:9fca2b23d0ba 608 int delay;
marcozecchini 0:9fca2b23d0ba 609 int period;
marcozecchini 0:9fca2b23d0ba 610
marcozecchini 0:9fca2b23d0ba 611 int (*post)(struct event *, A0 a0);
marcozecchini 0:9fca2b23d0ba 612 void (*dtor)(struct event *);
marcozecchini 0:9fca2b23d0ba 613
marcozecchini 0:9fca2b23d0ba 614 // F follows
marcozecchini 0:9fca2b23d0ba 615 } *_event;
marcozecchini 0:9fca2b23d0ba 616
marcozecchini 0:9fca2b23d0ba 617 // Event attributes
marcozecchini 0:9fca2b23d0ba 618 template <typename F>
marcozecchini 0:9fca2b23d0ba 619 static int event_post(struct event *e, A0 a0) {
marcozecchini 0:9fca2b23d0ba 620 typedef EventQueue::context10<F, A0> C;
marcozecchini 0:9fca2b23d0ba 621 void *p = equeue_alloc(e->equeue, sizeof(C));
marcozecchini 0:9fca2b23d0ba 622 if (!p) {
marcozecchini 0:9fca2b23d0ba 623 return 0;
marcozecchini 0:9fca2b23d0ba 624 }
marcozecchini 0:9fca2b23d0ba 625
marcozecchini 0:9fca2b23d0ba 626 new (p) C(*(F*)(e + 1), a0);
marcozecchini 0:9fca2b23d0ba 627 equeue_event_delay(p, e->delay);
marcozecchini 0:9fca2b23d0ba 628 equeue_event_period(p, e->period);
marcozecchini 0:9fca2b23d0ba 629 equeue_event_dtor(p, &EventQueue::function_dtor<C>);
marcozecchini 0:9fca2b23d0ba 630 return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
marcozecchini 0:9fca2b23d0ba 631 }
marcozecchini 0:9fca2b23d0ba 632
marcozecchini 0:9fca2b23d0ba 633 template <typename F>
marcozecchini 0:9fca2b23d0ba 634 static void event_dtor(struct event *e) {
marcozecchini 0:9fca2b23d0ba 635 ((F*)(e + 1))->~F();
marcozecchini 0:9fca2b23d0ba 636 }
marcozecchini 0:9fca2b23d0ba 637
marcozecchini 0:9fca2b23d0ba 638 public:
marcozecchini 0:9fca2b23d0ba 639 /** Create an event
marcozecchini 0:9fca2b23d0ba 640 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 641 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 642 * @param c0 Argument to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 643 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 644 * memory pool. Must be type-compatible with b0, the
marcozecchini 0:9fca2b23d0ba 645 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 646 */
marcozecchini 0:9fca2b23d0ba 647 template <typename F, typename C0>
marcozecchini 0:9fca2b23d0ba 648 Event(EventQueue *q, F f, C0 c0) {
marcozecchini 0:9fca2b23d0ba 649 new (this) Event(q, EventQueue::context11<F, C0, A0>(f, c0));
marcozecchini 0:9fca2b23d0ba 650 }
marcozecchini 0:9fca2b23d0ba 651
marcozecchini 0:9fca2b23d0ba 652 /** Create an event
marcozecchini 0:9fca2b23d0ba 653 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 654 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 655 * @param c0,c1 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 656 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 657 * memory pool. Must be type-compatible with b0..b1, the
marcozecchini 0:9fca2b23d0ba 658 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 659 */
marcozecchini 0:9fca2b23d0ba 660 template <typename F, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 661 Event(EventQueue *q, F f, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 662 new (this) Event(q, EventQueue::context21<F, C0, C1, A0>(f, c0, c1));
marcozecchini 0:9fca2b23d0ba 663 }
marcozecchini 0:9fca2b23d0ba 664
marcozecchini 0:9fca2b23d0ba 665 /** Create an event
marcozecchini 0:9fca2b23d0ba 666 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 667 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 668 * @param c0,c1,c2 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 669 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 670 * memory pool. Must be type-compatible with b0..b2, the
marcozecchini 0:9fca2b23d0ba 671 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 672 */
marcozecchini 0:9fca2b23d0ba 673 template <typename F, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 674 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 675 new (this) Event(q, EventQueue::context31<F, C0, C1, C2, A0>(f, c0, c1, c2));
marcozecchini 0:9fca2b23d0ba 676 }
marcozecchini 0:9fca2b23d0ba 677
marcozecchini 0:9fca2b23d0ba 678 /** Create an event
marcozecchini 0:9fca2b23d0ba 679 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 680 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 681 * @param c0,c1,c2,c3 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 682 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 683 * memory pool. Must be type-compatible with b0..b3, the
marcozecchini 0:9fca2b23d0ba 684 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 685 */
marcozecchini 0:9fca2b23d0ba 686 template <typename F, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 687 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 688 new (this) Event(q, EventQueue::context41<F, C0, C1, C2, C3, A0>(f, c0, c1, c2, c3));
marcozecchini 0:9fca2b23d0ba 689 }
marcozecchini 0:9fca2b23d0ba 690
marcozecchini 0:9fca2b23d0ba 691 /** Create an event
marcozecchini 0:9fca2b23d0ba 692 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 693 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 694 * @param c0,c1,c2,c3,c4 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 695 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 696 * memory pool. Must be type-compatible with b0..b4, the
marcozecchini 0:9fca2b23d0ba 697 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 698 */
marcozecchini 0:9fca2b23d0ba 699 template <typename F, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 700 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 701 new (this) Event(q, EventQueue::context51<F, C0, C1, C2, C3, C4, A0>(f, c0, c1, c2, c3, c4));
marcozecchini 0:9fca2b23d0ba 702 }
marcozecchini 0:9fca2b23d0ba 703
marcozecchini 0:9fca2b23d0ba 704 /** Create an event
marcozecchini 0:9fca2b23d0ba 705 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 706 */
marcozecchini 0:9fca2b23d0ba 707 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 708 Event(EventQueue *q, T *obj, R (T::*method)(B0, A0), B0 b0) {
marcozecchini 0:9fca2b23d0ba 709 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 710 }
marcozecchini 0:9fca2b23d0ba 711
marcozecchini 0:9fca2b23d0ba 712 /** Create an event
marcozecchini 0:9fca2b23d0ba 713 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 714 */
marcozecchini 0:9fca2b23d0ba 715 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 716 Event(EventQueue *q, const T *obj, R (T::*method)(B0, A0) const, B0 b0) {
marcozecchini 0:9fca2b23d0ba 717 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 718 }
marcozecchini 0:9fca2b23d0ba 719
marcozecchini 0:9fca2b23d0ba 720 /** Create an event
marcozecchini 0:9fca2b23d0ba 721 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 722 */
marcozecchini 0:9fca2b23d0ba 723 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 724 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, A0) volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 725 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 726 }
marcozecchini 0:9fca2b23d0ba 727
marcozecchini 0:9fca2b23d0ba 728 /** Create an event
marcozecchini 0:9fca2b23d0ba 729 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 730 */
marcozecchini 0:9fca2b23d0ba 731 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 732 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, A0) const volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 733 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 734 }
marcozecchini 0:9fca2b23d0ba 735
marcozecchini 0:9fca2b23d0ba 736 /** Create an event
marcozecchini 0:9fca2b23d0ba 737 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 738 */
marcozecchini 0:9fca2b23d0ba 739 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 740 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, A0), B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 741 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 742 }
marcozecchini 0:9fca2b23d0ba 743
marcozecchini 0:9fca2b23d0ba 744 /** Create an event
marcozecchini 0:9fca2b23d0ba 745 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 746 */
marcozecchini 0:9fca2b23d0ba 747 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 748 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, A0) const, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 749 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 750 }
marcozecchini 0:9fca2b23d0ba 751
marcozecchini 0:9fca2b23d0ba 752 /** Create an event
marcozecchini 0:9fca2b23d0ba 753 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 754 */
marcozecchini 0:9fca2b23d0ba 755 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 756 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, A0) volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 757 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 758 }
marcozecchini 0:9fca2b23d0ba 759
marcozecchini 0:9fca2b23d0ba 760 /** Create an event
marcozecchini 0:9fca2b23d0ba 761 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 762 */
marcozecchini 0:9fca2b23d0ba 763 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 764 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, A0) const volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 765 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 766 }
marcozecchini 0:9fca2b23d0ba 767
marcozecchini 0:9fca2b23d0ba 768 /** Create an event
marcozecchini 0:9fca2b23d0ba 769 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 770 */
marcozecchini 0:9fca2b23d0ba 771 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 772 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, A0), B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 773 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 774 }
marcozecchini 0:9fca2b23d0ba 775
marcozecchini 0:9fca2b23d0ba 776 /** Create an event
marcozecchini 0:9fca2b23d0ba 777 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 778 */
marcozecchini 0:9fca2b23d0ba 779 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 780 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, A0) const, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 781 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 782 }
marcozecchini 0:9fca2b23d0ba 783
marcozecchini 0:9fca2b23d0ba 784 /** Create an event
marcozecchini 0:9fca2b23d0ba 785 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 786 */
marcozecchini 0:9fca2b23d0ba 787 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 788 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, A0) volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 789 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 790 }
marcozecchini 0:9fca2b23d0ba 791
marcozecchini 0:9fca2b23d0ba 792 /** Create an event
marcozecchini 0:9fca2b23d0ba 793 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 794 */
marcozecchini 0:9fca2b23d0ba 795 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 796 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, A0) const volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 797 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 798 }
marcozecchini 0:9fca2b23d0ba 799
marcozecchini 0:9fca2b23d0ba 800 /** Create an event
marcozecchini 0:9fca2b23d0ba 801 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 802 */
marcozecchini 0:9fca2b23d0ba 803 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 804 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, A0), B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 805 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 806 }
marcozecchini 0:9fca2b23d0ba 807
marcozecchini 0:9fca2b23d0ba 808 /** Create an event
marcozecchini 0:9fca2b23d0ba 809 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 810 */
marcozecchini 0:9fca2b23d0ba 811 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 812 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, A0) const, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 813 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 814 }
marcozecchini 0:9fca2b23d0ba 815
marcozecchini 0:9fca2b23d0ba 816 /** Create an event
marcozecchini 0:9fca2b23d0ba 817 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 818 */
marcozecchini 0:9fca2b23d0ba 819 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 820 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0) volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 821 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 822 }
marcozecchini 0:9fca2b23d0ba 823
marcozecchini 0:9fca2b23d0ba 824 /** Create an event
marcozecchini 0:9fca2b23d0ba 825 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 826 */
marcozecchini 0:9fca2b23d0ba 827 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 828 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0) const volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 829 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 830 }
marcozecchini 0:9fca2b23d0ba 831
marcozecchini 0:9fca2b23d0ba 832 /** Create an event
marcozecchini 0:9fca2b23d0ba 833 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 834 */
marcozecchini 0:9fca2b23d0ba 835 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 836 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0), B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 837 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 838 }
marcozecchini 0:9fca2b23d0ba 839
marcozecchini 0:9fca2b23d0ba 840 /** Create an event
marcozecchini 0:9fca2b23d0ba 841 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 842 */
marcozecchini 0:9fca2b23d0ba 843 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 844 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0) const, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 845 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 846 }
marcozecchini 0:9fca2b23d0ba 847
marcozecchini 0:9fca2b23d0ba 848 /** Create an event
marcozecchini 0:9fca2b23d0ba 849 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 850 */
marcozecchini 0:9fca2b23d0ba 851 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 852 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0) volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 853 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 854 }
marcozecchini 0:9fca2b23d0ba 855
marcozecchini 0:9fca2b23d0ba 856 /** Create an event
marcozecchini 0:9fca2b23d0ba 857 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 858 */
marcozecchini 0:9fca2b23d0ba 859 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 860 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0) const volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 861 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 862 }
marcozecchini 0:9fca2b23d0ba 863 };
marcozecchini 0:9fca2b23d0ba 864
marcozecchini 0:9fca2b23d0ba 865 /** Event
marcozecchini 0:9fca2b23d0ba 866 *
marcozecchini 0:9fca2b23d0ba 867 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 868 * @ingroup events
marcozecchini 0:9fca2b23d0ba 869 */
marcozecchini 0:9fca2b23d0ba 870 template <typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 871 class Event<void(A0, A1)> {
marcozecchini 0:9fca2b23d0ba 872 public:
marcozecchini 0:9fca2b23d0ba 873 /** Create an event
marcozecchini 0:9fca2b23d0ba 874 *
marcozecchini 0:9fca2b23d0ba 875 * Constructs an event bound to the specified event queue. The specified
marcozecchini 0:9fca2b23d0ba 876 * callback acts as the target for the event and is executed in the
marcozecchini 0:9fca2b23d0ba 877 * context of the event queue's dispatch loop once posted.
marcozecchini 0:9fca2b23d0ba 878 *
marcozecchini 0:9fca2b23d0ba 879 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 880 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 881 */
marcozecchini 0:9fca2b23d0ba 882 template <typename F>
marcozecchini 0:9fca2b23d0ba 883 Event(EventQueue *q, F f) {
marcozecchini 0:9fca2b23d0ba 884 _event = static_cast<struct event *>(
marcozecchini 0:9fca2b23d0ba 885 equeue_alloc(&q->_equeue, sizeof(struct event) + sizeof(F)));
marcozecchini 0:9fca2b23d0ba 886
marcozecchini 0:9fca2b23d0ba 887 if (_event) {
marcozecchini 0:9fca2b23d0ba 888 _event->equeue = &q->_equeue;
marcozecchini 0:9fca2b23d0ba 889 _event->id = 0;
marcozecchini 0:9fca2b23d0ba 890 _event->delay = 0;
marcozecchini 0:9fca2b23d0ba 891 _event->period = -1;
marcozecchini 0:9fca2b23d0ba 892
marcozecchini 0:9fca2b23d0ba 893 _event->post = &Event::event_post<F>;
marcozecchini 0:9fca2b23d0ba 894 _event->dtor = &Event::event_dtor<F>;
marcozecchini 0:9fca2b23d0ba 895
marcozecchini 0:9fca2b23d0ba 896 new (_event+1) F(f);
marcozecchini 0:9fca2b23d0ba 897
marcozecchini 0:9fca2b23d0ba 898 _event->ref = 1;
marcozecchini 0:9fca2b23d0ba 899 }
marcozecchini 0:9fca2b23d0ba 900 }
marcozecchini 0:9fca2b23d0ba 901
marcozecchini 0:9fca2b23d0ba 902 /** Copy constructor for events
marcozecchini 0:9fca2b23d0ba 903 */
marcozecchini 0:9fca2b23d0ba 904 Event(const Event &e) {
marcozecchini 0:9fca2b23d0ba 905 _event = 0;
marcozecchini 0:9fca2b23d0ba 906 if (e._event) {
marcozecchini 0:9fca2b23d0ba 907 _event = e._event;
marcozecchini 0:9fca2b23d0ba 908 _event->ref += 1;
marcozecchini 0:9fca2b23d0ba 909 }
marcozecchini 0:9fca2b23d0ba 910 }
marcozecchini 0:9fca2b23d0ba 911
marcozecchini 0:9fca2b23d0ba 912 /** Assignment operator for events
marcozecchini 0:9fca2b23d0ba 913 */
marcozecchini 0:9fca2b23d0ba 914 Event &operator=(const Event &that) {
marcozecchini 0:9fca2b23d0ba 915 if (this != &that) {
marcozecchini 0:9fca2b23d0ba 916 this->~Event();
marcozecchini 0:9fca2b23d0ba 917 new (this) Event(that);
marcozecchini 0:9fca2b23d0ba 918 }
marcozecchini 0:9fca2b23d0ba 919
marcozecchini 0:9fca2b23d0ba 920 return *this;
marcozecchini 0:9fca2b23d0ba 921 }
marcozecchini 0:9fca2b23d0ba 922
marcozecchini 0:9fca2b23d0ba 923 /** Destructor for events
marcozecchini 0:9fca2b23d0ba 924 */
marcozecchini 0:9fca2b23d0ba 925 ~Event() {
marcozecchini 0:9fca2b23d0ba 926 if (_event) {
marcozecchini 0:9fca2b23d0ba 927 _event->ref -= 1;
marcozecchini 0:9fca2b23d0ba 928 if (_event->ref == 0) {
marcozecchini 0:9fca2b23d0ba 929 _event->dtor(_event);
marcozecchini 0:9fca2b23d0ba 930 equeue_dealloc(_event->equeue, _event);
marcozecchini 0:9fca2b23d0ba 931 }
marcozecchini 0:9fca2b23d0ba 932 }
marcozecchini 0:9fca2b23d0ba 933 }
marcozecchini 0:9fca2b23d0ba 934
marcozecchini 0:9fca2b23d0ba 935 /** Configure the delay of an event
marcozecchini 0:9fca2b23d0ba 936 *
marcozecchini 0:9fca2b23d0ba 937 * @param delay Millisecond delay before dispatching the event
marcozecchini 0:9fca2b23d0ba 938 */
marcozecchini 0:9fca2b23d0ba 939 void delay(int delay) {
marcozecchini 0:9fca2b23d0ba 940 if (_event) {
marcozecchini 0:9fca2b23d0ba 941 _event->delay = delay;
marcozecchini 0:9fca2b23d0ba 942 }
marcozecchini 0:9fca2b23d0ba 943 }
marcozecchini 0:9fca2b23d0ba 944
marcozecchini 0:9fca2b23d0ba 945 /** Configure the period of an event
marcozecchini 0:9fca2b23d0ba 946 *
marcozecchini 0:9fca2b23d0ba 947 * @param period Millisecond period for repeatedly dispatching an event
marcozecchini 0:9fca2b23d0ba 948 */
marcozecchini 0:9fca2b23d0ba 949 void period(int period) {
marcozecchini 0:9fca2b23d0ba 950 if (_event) {
marcozecchini 0:9fca2b23d0ba 951 _event->period = period;
marcozecchini 0:9fca2b23d0ba 952 }
marcozecchini 0:9fca2b23d0ba 953 }
marcozecchini 0:9fca2b23d0ba 954
marcozecchini 0:9fca2b23d0ba 955 /** Posts an event onto the underlying event queue
marcozecchini 0:9fca2b23d0ba 956 *
marcozecchini 0:9fca2b23d0ba 957 * The event is posted to the underlying queue and is executed in the
marcozecchini 0:9fca2b23d0ba 958 * context of the event queue's dispatch loop.
marcozecchini 0:9fca2b23d0ba 959 *
marcozecchini 0:9fca2b23d0ba 960 * The post function is irq safe and can act as a mechanism for moving
marcozecchini 0:9fca2b23d0ba 961 * events out of irq contexts.
marcozecchini 0:9fca2b23d0ba 962 *
marcozecchini 0:9fca2b23d0ba 963 * @param a0,a1 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 964 * @return A unique id that represents the posted event and can
marcozecchini 0:9fca2b23d0ba 965 * be passed to EventQueue::cancel, or an id of 0 if
marcozecchini 0:9fca2b23d0ba 966 * there is not enough memory to allocate the event.
marcozecchini 0:9fca2b23d0ba 967 */
marcozecchini 0:9fca2b23d0ba 968 int post(A0 a0, A1 a1) const {
marcozecchini 0:9fca2b23d0ba 969 if (!_event) {
marcozecchini 0:9fca2b23d0ba 970 return 0;
marcozecchini 0:9fca2b23d0ba 971 }
marcozecchini 0:9fca2b23d0ba 972
marcozecchini 0:9fca2b23d0ba 973 _event->id = _event->post(_event, a0, a1);
marcozecchini 0:9fca2b23d0ba 974 return _event->id;
marcozecchini 0:9fca2b23d0ba 975 }
marcozecchini 0:9fca2b23d0ba 976
marcozecchini 0:9fca2b23d0ba 977 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 978 *
marcozecchini 0:9fca2b23d0ba 979 * @param a0,a1 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 980 */
marcozecchini 0:9fca2b23d0ba 981 void call(A0 a0, A1 a1) const {
marcozecchini 0:9fca2b23d0ba 982 MBED_UNUSED int id = post(a0, a1);
marcozecchini 0:9fca2b23d0ba 983 MBED_ASSERT(id);
marcozecchini 0:9fca2b23d0ba 984 }
marcozecchini 0:9fca2b23d0ba 985
marcozecchini 0:9fca2b23d0ba 986 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 987 *
marcozecchini 0:9fca2b23d0ba 988 * @param a0,a1 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 989 */
marcozecchini 0:9fca2b23d0ba 990 void operator()(A0 a0, A1 a1) const {
marcozecchini 0:9fca2b23d0ba 991 return call(a0, a1);
marcozecchini 0:9fca2b23d0ba 992 }
marcozecchini 0:9fca2b23d0ba 993
marcozecchini 0:9fca2b23d0ba 994 /** Static thunk for passing as C-style function
marcozecchini 0:9fca2b23d0ba 995 *
marcozecchini 0:9fca2b23d0ba 996 * @param func Event to call passed as a void pointer
marcozecchini 0:9fca2b23d0ba 997 * @param a0,a1 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 998 */
marcozecchini 0:9fca2b23d0ba 999 static void thunk(void *func, A0 a0, A1 a1) {
marcozecchini 0:9fca2b23d0ba 1000 return static_cast<Event*>(func)->call(a0, a1);
marcozecchini 0:9fca2b23d0ba 1001 }
marcozecchini 0:9fca2b23d0ba 1002
marcozecchini 0:9fca2b23d0ba 1003 /** Cancels the most recently posted event
marcozecchini 0:9fca2b23d0ba 1004 *
marcozecchini 0:9fca2b23d0ba 1005 * Attempts to cancel the most recently posted event. It is safe to call
marcozecchini 0:9fca2b23d0ba 1006 * cancel after an event has already been dispatched.
marcozecchini 0:9fca2b23d0ba 1007 *
marcozecchini 0:9fca2b23d0ba 1008 * The cancel function is irq safe.
marcozecchini 0:9fca2b23d0ba 1009 *
marcozecchini 0:9fca2b23d0ba 1010 * If called while the event queue's dispatch loop is active, the cancel
marcozecchini 0:9fca2b23d0ba 1011 * function does not garuntee that the event will not execute after it
marcozecchini 0:9fca2b23d0ba 1012 * returns, as the event may have already begun executing.
marcozecchini 0:9fca2b23d0ba 1013 */
marcozecchini 0:9fca2b23d0ba 1014 void cancel() const {
marcozecchini 0:9fca2b23d0ba 1015 if (_event) {
marcozecchini 0:9fca2b23d0ba 1016 equeue_cancel(_event->equeue, _event->id);
marcozecchini 0:9fca2b23d0ba 1017 }
marcozecchini 0:9fca2b23d0ba 1018 }
marcozecchini 0:9fca2b23d0ba 1019
marcozecchini 0:9fca2b23d0ba 1020 private:
marcozecchini 0:9fca2b23d0ba 1021 struct event {
marcozecchini 0:9fca2b23d0ba 1022 unsigned ref;
marcozecchini 0:9fca2b23d0ba 1023 equeue_t *equeue;
marcozecchini 0:9fca2b23d0ba 1024 int id;
marcozecchini 0:9fca2b23d0ba 1025
marcozecchini 0:9fca2b23d0ba 1026 int delay;
marcozecchini 0:9fca2b23d0ba 1027 int period;
marcozecchini 0:9fca2b23d0ba 1028
marcozecchini 0:9fca2b23d0ba 1029 int (*post)(struct event *, A0 a0, A1 a1);
marcozecchini 0:9fca2b23d0ba 1030 void (*dtor)(struct event *);
marcozecchini 0:9fca2b23d0ba 1031
marcozecchini 0:9fca2b23d0ba 1032 // F follows
marcozecchini 0:9fca2b23d0ba 1033 } *_event;
marcozecchini 0:9fca2b23d0ba 1034
marcozecchini 0:9fca2b23d0ba 1035 // Event attributes
marcozecchini 0:9fca2b23d0ba 1036 template <typename F>
marcozecchini 0:9fca2b23d0ba 1037 static int event_post(struct event *e, A0 a0, A1 a1) {
marcozecchini 0:9fca2b23d0ba 1038 typedef EventQueue::context20<F, A0, A1> C;
marcozecchini 0:9fca2b23d0ba 1039 void *p = equeue_alloc(e->equeue, sizeof(C));
marcozecchini 0:9fca2b23d0ba 1040 if (!p) {
marcozecchini 0:9fca2b23d0ba 1041 return 0;
marcozecchini 0:9fca2b23d0ba 1042 }
marcozecchini 0:9fca2b23d0ba 1043
marcozecchini 0:9fca2b23d0ba 1044 new (p) C(*(F*)(e + 1), a0, a1);
marcozecchini 0:9fca2b23d0ba 1045 equeue_event_delay(p, e->delay);
marcozecchini 0:9fca2b23d0ba 1046 equeue_event_period(p, e->period);
marcozecchini 0:9fca2b23d0ba 1047 equeue_event_dtor(p, &EventQueue::function_dtor<C>);
marcozecchini 0:9fca2b23d0ba 1048 return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
marcozecchini 0:9fca2b23d0ba 1049 }
marcozecchini 0:9fca2b23d0ba 1050
marcozecchini 0:9fca2b23d0ba 1051 template <typename F>
marcozecchini 0:9fca2b23d0ba 1052 static void event_dtor(struct event *e) {
marcozecchini 0:9fca2b23d0ba 1053 ((F*)(e + 1))->~F();
marcozecchini 0:9fca2b23d0ba 1054 }
marcozecchini 0:9fca2b23d0ba 1055
marcozecchini 0:9fca2b23d0ba 1056 public:
marcozecchini 0:9fca2b23d0ba 1057 /** Create an event
marcozecchini 0:9fca2b23d0ba 1058 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1059 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1060 * @param c0 Argument to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1061 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1062 * memory pool. Must be type-compatible with b0, the
marcozecchini 0:9fca2b23d0ba 1063 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1064 */
marcozecchini 0:9fca2b23d0ba 1065 template <typename F, typename C0>
marcozecchini 0:9fca2b23d0ba 1066 Event(EventQueue *q, F f, C0 c0) {
marcozecchini 0:9fca2b23d0ba 1067 new (this) Event(q, EventQueue::context12<F, C0, A0, A1>(f, c0));
marcozecchini 0:9fca2b23d0ba 1068 }
marcozecchini 0:9fca2b23d0ba 1069
marcozecchini 0:9fca2b23d0ba 1070 /** Create an event
marcozecchini 0:9fca2b23d0ba 1071 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1072 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1073 * @param c0,c1 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1074 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1075 * memory pool. Must be type-compatible with b0..b1, the
marcozecchini 0:9fca2b23d0ba 1076 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1077 */
marcozecchini 0:9fca2b23d0ba 1078 template <typename F, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 1079 Event(EventQueue *q, F f, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 1080 new (this) Event(q, EventQueue::context22<F, C0, C1, A0, A1>(f, c0, c1));
marcozecchini 0:9fca2b23d0ba 1081 }
marcozecchini 0:9fca2b23d0ba 1082
marcozecchini 0:9fca2b23d0ba 1083 /** Create an event
marcozecchini 0:9fca2b23d0ba 1084 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1085 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1086 * @param c0,c1,c2 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1087 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1088 * memory pool. Must be type-compatible with b0..b2, the
marcozecchini 0:9fca2b23d0ba 1089 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1090 */
marcozecchini 0:9fca2b23d0ba 1091 template <typename F, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 1092 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 1093 new (this) Event(q, EventQueue::context32<F, C0, C1, C2, A0, A1>(f, c0, c1, c2));
marcozecchini 0:9fca2b23d0ba 1094 }
marcozecchini 0:9fca2b23d0ba 1095
marcozecchini 0:9fca2b23d0ba 1096 /** Create an event
marcozecchini 0:9fca2b23d0ba 1097 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1098 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1099 * @param c0,c1,c2,c3 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1100 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1101 * memory pool. Must be type-compatible with b0..b3, the
marcozecchini 0:9fca2b23d0ba 1102 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1103 */
marcozecchini 0:9fca2b23d0ba 1104 template <typename F, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 1105 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 1106 new (this) Event(q, EventQueue::context42<F, C0, C1, C2, C3, A0, A1>(f, c0, c1, c2, c3));
marcozecchini 0:9fca2b23d0ba 1107 }
marcozecchini 0:9fca2b23d0ba 1108
marcozecchini 0:9fca2b23d0ba 1109 /** Create an event
marcozecchini 0:9fca2b23d0ba 1110 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1111 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1112 * @param c0,c1,c2,c3,c4 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1113 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1114 * memory pool. Must be type-compatible with b0..b4, the
marcozecchini 0:9fca2b23d0ba 1115 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1116 */
marcozecchini 0:9fca2b23d0ba 1117 template <typename F, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 1118 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 1119 new (this) Event(q, EventQueue::context52<F, C0, C1, C2, C3, C4, A0, A1>(f, c0, c1, c2, c3, c4));
marcozecchini 0:9fca2b23d0ba 1120 }
marcozecchini 0:9fca2b23d0ba 1121
marcozecchini 0:9fca2b23d0ba 1122 /** Create an event
marcozecchini 0:9fca2b23d0ba 1123 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1124 */
marcozecchini 0:9fca2b23d0ba 1125 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1126 Event(EventQueue *q, T *obj, R (T::*method)(B0, A0, A1), B0 b0) {
marcozecchini 0:9fca2b23d0ba 1127 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1128 }
marcozecchini 0:9fca2b23d0ba 1129
marcozecchini 0:9fca2b23d0ba 1130 /** Create an event
marcozecchini 0:9fca2b23d0ba 1131 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1132 */
marcozecchini 0:9fca2b23d0ba 1133 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1134 Event(EventQueue *q, const T *obj, R (T::*method)(B0, A0, A1) const, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1135 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1136 }
marcozecchini 0:9fca2b23d0ba 1137
marcozecchini 0:9fca2b23d0ba 1138 /** Create an event
marcozecchini 0:9fca2b23d0ba 1139 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1140 */
marcozecchini 0:9fca2b23d0ba 1141 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1142 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, A0, A1) volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1143 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1144 }
marcozecchini 0:9fca2b23d0ba 1145
marcozecchini 0:9fca2b23d0ba 1146 /** Create an event
marcozecchini 0:9fca2b23d0ba 1147 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1148 */
marcozecchini 0:9fca2b23d0ba 1149 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1150 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, A0, A1) const volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1151 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1152 }
marcozecchini 0:9fca2b23d0ba 1153
marcozecchini 0:9fca2b23d0ba 1154 /** Create an event
marcozecchini 0:9fca2b23d0ba 1155 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1156 */
marcozecchini 0:9fca2b23d0ba 1157 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1158 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, A0, A1), B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1159 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1160 }
marcozecchini 0:9fca2b23d0ba 1161
marcozecchini 0:9fca2b23d0ba 1162 /** Create an event
marcozecchini 0:9fca2b23d0ba 1163 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1164 */
marcozecchini 0:9fca2b23d0ba 1165 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1166 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, A0, A1) const, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1167 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1168 }
marcozecchini 0:9fca2b23d0ba 1169
marcozecchini 0:9fca2b23d0ba 1170 /** Create an event
marcozecchini 0:9fca2b23d0ba 1171 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1172 */
marcozecchini 0:9fca2b23d0ba 1173 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1174 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, A0, A1) volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1175 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1176 }
marcozecchini 0:9fca2b23d0ba 1177
marcozecchini 0:9fca2b23d0ba 1178 /** Create an event
marcozecchini 0:9fca2b23d0ba 1179 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1180 */
marcozecchini 0:9fca2b23d0ba 1181 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1182 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, A0, A1) const volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1183 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1184 }
marcozecchini 0:9fca2b23d0ba 1185
marcozecchini 0:9fca2b23d0ba 1186 /** Create an event
marcozecchini 0:9fca2b23d0ba 1187 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1188 */
marcozecchini 0:9fca2b23d0ba 1189 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1190 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, A0, A1), B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1191 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1192 }
marcozecchini 0:9fca2b23d0ba 1193
marcozecchini 0:9fca2b23d0ba 1194 /** Create an event
marcozecchini 0:9fca2b23d0ba 1195 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1196 */
marcozecchini 0:9fca2b23d0ba 1197 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1198 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, A0, A1) const, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1199 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1200 }
marcozecchini 0:9fca2b23d0ba 1201
marcozecchini 0:9fca2b23d0ba 1202 /** Create an event
marcozecchini 0:9fca2b23d0ba 1203 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1204 */
marcozecchini 0:9fca2b23d0ba 1205 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1206 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1) volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1207 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1208 }
marcozecchini 0:9fca2b23d0ba 1209
marcozecchini 0:9fca2b23d0ba 1210 /** Create an event
marcozecchini 0:9fca2b23d0ba 1211 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1212 */
marcozecchini 0:9fca2b23d0ba 1213 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1214 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1) const volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1215 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1216 }
marcozecchini 0:9fca2b23d0ba 1217
marcozecchini 0:9fca2b23d0ba 1218 /** Create an event
marcozecchini 0:9fca2b23d0ba 1219 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1220 */
marcozecchini 0:9fca2b23d0ba 1221 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1222 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1), B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1223 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1224 }
marcozecchini 0:9fca2b23d0ba 1225
marcozecchini 0:9fca2b23d0ba 1226 /** Create an event
marcozecchini 0:9fca2b23d0ba 1227 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1228 */
marcozecchini 0:9fca2b23d0ba 1229 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1230 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1) const, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1231 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1232 }
marcozecchini 0:9fca2b23d0ba 1233
marcozecchini 0:9fca2b23d0ba 1234 /** Create an event
marcozecchini 0:9fca2b23d0ba 1235 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1236 */
marcozecchini 0:9fca2b23d0ba 1237 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1238 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1) volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1239 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1240 }
marcozecchini 0:9fca2b23d0ba 1241
marcozecchini 0:9fca2b23d0ba 1242 /** Create an event
marcozecchini 0:9fca2b23d0ba 1243 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1244 */
marcozecchini 0:9fca2b23d0ba 1245 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1246 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1) const volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1247 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1248 }
marcozecchini 0:9fca2b23d0ba 1249
marcozecchini 0:9fca2b23d0ba 1250 /** Create an event
marcozecchini 0:9fca2b23d0ba 1251 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1252 */
marcozecchini 0:9fca2b23d0ba 1253 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1254 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1), B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1255 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1256 }
marcozecchini 0:9fca2b23d0ba 1257
marcozecchini 0:9fca2b23d0ba 1258 /** Create an event
marcozecchini 0:9fca2b23d0ba 1259 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1260 */
marcozecchini 0:9fca2b23d0ba 1261 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1262 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1) const, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1263 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1264 }
marcozecchini 0:9fca2b23d0ba 1265
marcozecchini 0:9fca2b23d0ba 1266 /** Create an event
marcozecchini 0:9fca2b23d0ba 1267 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1268 */
marcozecchini 0:9fca2b23d0ba 1269 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1270 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1) volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1271 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1272 }
marcozecchini 0:9fca2b23d0ba 1273
marcozecchini 0:9fca2b23d0ba 1274 /** Create an event
marcozecchini 0:9fca2b23d0ba 1275 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1276 */
marcozecchini 0:9fca2b23d0ba 1277 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1278 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1) const volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1279 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1280 }
marcozecchini 0:9fca2b23d0ba 1281 };
marcozecchini 0:9fca2b23d0ba 1282
marcozecchini 0:9fca2b23d0ba 1283 /** Event
marcozecchini 0:9fca2b23d0ba 1284 *
marcozecchini 0:9fca2b23d0ba 1285 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 1286 * @ingroup events
marcozecchini 0:9fca2b23d0ba 1287 */
marcozecchini 0:9fca2b23d0ba 1288 template <typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 1289 class Event<void(A0, A1, A2)> {
marcozecchini 0:9fca2b23d0ba 1290 public:
marcozecchini 0:9fca2b23d0ba 1291 /** Create an event
marcozecchini 0:9fca2b23d0ba 1292 *
marcozecchini 0:9fca2b23d0ba 1293 * Constructs an event bound to the specified event queue. The specified
marcozecchini 0:9fca2b23d0ba 1294 * callback acts as the target for the event and is executed in the
marcozecchini 0:9fca2b23d0ba 1295 * context of the event queue's dispatch loop once posted.
marcozecchini 0:9fca2b23d0ba 1296 *
marcozecchini 0:9fca2b23d0ba 1297 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1298 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1299 */
marcozecchini 0:9fca2b23d0ba 1300 template <typename F>
marcozecchini 0:9fca2b23d0ba 1301 Event(EventQueue *q, F f) {
marcozecchini 0:9fca2b23d0ba 1302 _event = static_cast<struct event *>(
marcozecchini 0:9fca2b23d0ba 1303 equeue_alloc(&q->_equeue, sizeof(struct event) + sizeof(F)));
marcozecchini 0:9fca2b23d0ba 1304
marcozecchini 0:9fca2b23d0ba 1305 if (_event) {
marcozecchini 0:9fca2b23d0ba 1306 _event->equeue = &q->_equeue;
marcozecchini 0:9fca2b23d0ba 1307 _event->id = 0;
marcozecchini 0:9fca2b23d0ba 1308 _event->delay = 0;
marcozecchini 0:9fca2b23d0ba 1309 _event->period = -1;
marcozecchini 0:9fca2b23d0ba 1310
marcozecchini 0:9fca2b23d0ba 1311 _event->post = &Event::event_post<F>;
marcozecchini 0:9fca2b23d0ba 1312 _event->dtor = &Event::event_dtor<F>;
marcozecchini 0:9fca2b23d0ba 1313
marcozecchini 0:9fca2b23d0ba 1314 new (_event+1) F(f);
marcozecchini 0:9fca2b23d0ba 1315
marcozecchini 0:9fca2b23d0ba 1316 _event->ref = 1;
marcozecchini 0:9fca2b23d0ba 1317 }
marcozecchini 0:9fca2b23d0ba 1318 }
marcozecchini 0:9fca2b23d0ba 1319
marcozecchini 0:9fca2b23d0ba 1320 /** Copy constructor for events
marcozecchini 0:9fca2b23d0ba 1321 */
marcozecchini 0:9fca2b23d0ba 1322 Event(const Event &e) {
marcozecchini 0:9fca2b23d0ba 1323 _event = 0;
marcozecchini 0:9fca2b23d0ba 1324 if (e._event) {
marcozecchini 0:9fca2b23d0ba 1325 _event = e._event;
marcozecchini 0:9fca2b23d0ba 1326 _event->ref += 1;
marcozecchini 0:9fca2b23d0ba 1327 }
marcozecchini 0:9fca2b23d0ba 1328 }
marcozecchini 0:9fca2b23d0ba 1329
marcozecchini 0:9fca2b23d0ba 1330 /** Assignment operator for events
marcozecchini 0:9fca2b23d0ba 1331 */
marcozecchini 0:9fca2b23d0ba 1332 Event &operator=(const Event &that) {
marcozecchini 0:9fca2b23d0ba 1333 if (this != &that) {
marcozecchini 0:9fca2b23d0ba 1334 this->~Event();
marcozecchini 0:9fca2b23d0ba 1335 new (this) Event(that);
marcozecchini 0:9fca2b23d0ba 1336 }
marcozecchini 0:9fca2b23d0ba 1337
marcozecchini 0:9fca2b23d0ba 1338 return *this;
marcozecchini 0:9fca2b23d0ba 1339 }
marcozecchini 0:9fca2b23d0ba 1340
marcozecchini 0:9fca2b23d0ba 1341 /** Destructor for events
marcozecchini 0:9fca2b23d0ba 1342 */
marcozecchini 0:9fca2b23d0ba 1343 ~Event() {
marcozecchini 0:9fca2b23d0ba 1344 if (_event) {
marcozecchini 0:9fca2b23d0ba 1345 _event->ref -= 1;
marcozecchini 0:9fca2b23d0ba 1346 if (_event->ref == 0) {
marcozecchini 0:9fca2b23d0ba 1347 _event->dtor(_event);
marcozecchini 0:9fca2b23d0ba 1348 equeue_dealloc(_event->equeue, _event);
marcozecchini 0:9fca2b23d0ba 1349 }
marcozecchini 0:9fca2b23d0ba 1350 }
marcozecchini 0:9fca2b23d0ba 1351 }
marcozecchini 0:9fca2b23d0ba 1352
marcozecchini 0:9fca2b23d0ba 1353 /** Configure the delay of an event
marcozecchini 0:9fca2b23d0ba 1354 *
marcozecchini 0:9fca2b23d0ba 1355 * @param delay Millisecond delay before dispatching the event
marcozecchini 0:9fca2b23d0ba 1356 */
marcozecchini 0:9fca2b23d0ba 1357 void delay(int delay) {
marcozecchini 0:9fca2b23d0ba 1358 if (_event) {
marcozecchini 0:9fca2b23d0ba 1359 _event->delay = delay;
marcozecchini 0:9fca2b23d0ba 1360 }
marcozecchini 0:9fca2b23d0ba 1361 }
marcozecchini 0:9fca2b23d0ba 1362
marcozecchini 0:9fca2b23d0ba 1363 /** Configure the period of an event
marcozecchini 0:9fca2b23d0ba 1364 *
marcozecchini 0:9fca2b23d0ba 1365 * @param period Millisecond period for repeatedly dispatching an event
marcozecchini 0:9fca2b23d0ba 1366 */
marcozecchini 0:9fca2b23d0ba 1367 void period(int period) {
marcozecchini 0:9fca2b23d0ba 1368 if (_event) {
marcozecchini 0:9fca2b23d0ba 1369 _event->period = period;
marcozecchini 0:9fca2b23d0ba 1370 }
marcozecchini 0:9fca2b23d0ba 1371 }
marcozecchini 0:9fca2b23d0ba 1372
marcozecchini 0:9fca2b23d0ba 1373 /** Posts an event onto the underlying event queue
marcozecchini 0:9fca2b23d0ba 1374 *
marcozecchini 0:9fca2b23d0ba 1375 * The event is posted to the underlying queue and is executed in the
marcozecchini 0:9fca2b23d0ba 1376 * context of the event queue's dispatch loop.
marcozecchini 0:9fca2b23d0ba 1377 *
marcozecchini 0:9fca2b23d0ba 1378 * The post function is irq safe and can act as a mechanism for moving
marcozecchini 0:9fca2b23d0ba 1379 * events out of irq contexts.
marcozecchini 0:9fca2b23d0ba 1380 *
marcozecchini 0:9fca2b23d0ba 1381 * @param a0,a1,a2 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1382 * @return A unique id that represents the posted event and can
marcozecchini 0:9fca2b23d0ba 1383 * be passed to EventQueue::cancel, or an id of 0 if
marcozecchini 0:9fca2b23d0ba 1384 * there is not enough memory to allocate the event.
marcozecchini 0:9fca2b23d0ba 1385 */
marcozecchini 0:9fca2b23d0ba 1386 int post(A0 a0, A1 a1, A2 a2) const {
marcozecchini 0:9fca2b23d0ba 1387 if (!_event) {
marcozecchini 0:9fca2b23d0ba 1388 return 0;
marcozecchini 0:9fca2b23d0ba 1389 }
marcozecchini 0:9fca2b23d0ba 1390
marcozecchini 0:9fca2b23d0ba 1391 _event->id = _event->post(_event, a0, a1, a2);
marcozecchini 0:9fca2b23d0ba 1392 return _event->id;
marcozecchini 0:9fca2b23d0ba 1393 }
marcozecchini 0:9fca2b23d0ba 1394
marcozecchini 0:9fca2b23d0ba 1395 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 1396 *
marcozecchini 0:9fca2b23d0ba 1397 * @param a0,a1,a2 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1398 */
marcozecchini 0:9fca2b23d0ba 1399 void call(A0 a0, A1 a1, A2 a2) const {
marcozecchini 0:9fca2b23d0ba 1400 MBED_UNUSED int id = post(a0, a1, a2);
marcozecchini 0:9fca2b23d0ba 1401 MBED_ASSERT(id);
marcozecchini 0:9fca2b23d0ba 1402 }
marcozecchini 0:9fca2b23d0ba 1403
marcozecchini 0:9fca2b23d0ba 1404 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 1405 *
marcozecchini 0:9fca2b23d0ba 1406 * @param a0,a1,a2 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1407 */
marcozecchini 0:9fca2b23d0ba 1408 void operator()(A0 a0, A1 a1, A2 a2) const {
marcozecchini 0:9fca2b23d0ba 1409 return call(a0, a1, a2);
marcozecchini 0:9fca2b23d0ba 1410 }
marcozecchini 0:9fca2b23d0ba 1411
marcozecchini 0:9fca2b23d0ba 1412 /** Static thunk for passing as C-style function
marcozecchini 0:9fca2b23d0ba 1413 *
marcozecchini 0:9fca2b23d0ba 1414 * @param func Event to call passed as a void pointer
marcozecchini 0:9fca2b23d0ba 1415 * @param a0,a1,a2 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1416 */
marcozecchini 0:9fca2b23d0ba 1417 static void thunk(void *func, A0 a0, A1 a1, A2 a2) {
marcozecchini 0:9fca2b23d0ba 1418 return static_cast<Event*>(func)->call(a0, a1, a2);
marcozecchini 0:9fca2b23d0ba 1419 }
marcozecchini 0:9fca2b23d0ba 1420
marcozecchini 0:9fca2b23d0ba 1421 /** Cancels the most recently posted event
marcozecchini 0:9fca2b23d0ba 1422 *
marcozecchini 0:9fca2b23d0ba 1423 * Attempts to cancel the most recently posted event. It is safe to call
marcozecchini 0:9fca2b23d0ba 1424 * cancel after an event has already been dispatched.
marcozecchini 0:9fca2b23d0ba 1425 *
marcozecchini 0:9fca2b23d0ba 1426 * The cancel function is irq safe.
marcozecchini 0:9fca2b23d0ba 1427 *
marcozecchini 0:9fca2b23d0ba 1428 * If called while the event queue's dispatch loop is active, the cancel
marcozecchini 0:9fca2b23d0ba 1429 * function does not garuntee that the event will not execute after it
marcozecchini 0:9fca2b23d0ba 1430 * returns, as the event may have already begun executing.
marcozecchini 0:9fca2b23d0ba 1431 */
marcozecchini 0:9fca2b23d0ba 1432 void cancel() const {
marcozecchini 0:9fca2b23d0ba 1433 if (_event) {
marcozecchini 0:9fca2b23d0ba 1434 equeue_cancel(_event->equeue, _event->id);
marcozecchini 0:9fca2b23d0ba 1435 }
marcozecchini 0:9fca2b23d0ba 1436 }
marcozecchini 0:9fca2b23d0ba 1437
marcozecchini 0:9fca2b23d0ba 1438 private:
marcozecchini 0:9fca2b23d0ba 1439 struct event {
marcozecchini 0:9fca2b23d0ba 1440 unsigned ref;
marcozecchini 0:9fca2b23d0ba 1441 equeue_t *equeue;
marcozecchini 0:9fca2b23d0ba 1442 int id;
marcozecchini 0:9fca2b23d0ba 1443
marcozecchini 0:9fca2b23d0ba 1444 int delay;
marcozecchini 0:9fca2b23d0ba 1445 int period;
marcozecchini 0:9fca2b23d0ba 1446
marcozecchini 0:9fca2b23d0ba 1447 int (*post)(struct event *, A0 a0, A1 a1, A2 a2);
marcozecchini 0:9fca2b23d0ba 1448 void (*dtor)(struct event *);
marcozecchini 0:9fca2b23d0ba 1449
marcozecchini 0:9fca2b23d0ba 1450 // F follows
marcozecchini 0:9fca2b23d0ba 1451 } *_event;
marcozecchini 0:9fca2b23d0ba 1452
marcozecchini 0:9fca2b23d0ba 1453 // Event attributes
marcozecchini 0:9fca2b23d0ba 1454 template <typename F>
marcozecchini 0:9fca2b23d0ba 1455 static int event_post(struct event *e, A0 a0, A1 a1, A2 a2) {
marcozecchini 0:9fca2b23d0ba 1456 typedef EventQueue::context30<F, A0, A1, A2> C;
marcozecchini 0:9fca2b23d0ba 1457 void *p = equeue_alloc(e->equeue, sizeof(C));
marcozecchini 0:9fca2b23d0ba 1458 if (!p) {
marcozecchini 0:9fca2b23d0ba 1459 return 0;
marcozecchini 0:9fca2b23d0ba 1460 }
marcozecchini 0:9fca2b23d0ba 1461
marcozecchini 0:9fca2b23d0ba 1462 new (p) C(*(F*)(e + 1), a0, a1, a2);
marcozecchini 0:9fca2b23d0ba 1463 equeue_event_delay(p, e->delay);
marcozecchini 0:9fca2b23d0ba 1464 equeue_event_period(p, e->period);
marcozecchini 0:9fca2b23d0ba 1465 equeue_event_dtor(p, &EventQueue::function_dtor<C>);
marcozecchini 0:9fca2b23d0ba 1466 return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
marcozecchini 0:9fca2b23d0ba 1467 }
marcozecchini 0:9fca2b23d0ba 1468
marcozecchini 0:9fca2b23d0ba 1469 template <typename F>
marcozecchini 0:9fca2b23d0ba 1470 static void event_dtor(struct event *e) {
marcozecchini 0:9fca2b23d0ba 1471 ((F*)(e + 1))->~F();
marcozecchini 0:9fca2b23d0ba 1472 }
marcozecchini 0:9fca2b23d0ba 1473
marcozecchini 0:9fca2b23d0ba 1474 public:
marcozecchini 0:9fca2b23d0ba 1475 /** Create an event
marcozecchini 0:9fca2b23d0ba 1476 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1477 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1478 * @param c0 Argument to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1479 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1480 * memory pool. Must be type-compatible with b0, the
marcozecchini 0:9fca2b23d0ba 1481 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1482 */
marcozecchini 0:9fca2b23d0ba 1483 template <typename F, typename C0>
marcozecchini 0:9fca2b23d0ba 1484 Event(EventQueue *q, F f, C0 c0) {
marcozecchini 0:9fca2b23d0ba 1485 new (this) Event(q, EventQueue::context13<F, C0, A0, A1, A2>(f, c0));
marcozecchini 0:9fca2b23d0ba 1486 }
marcozecchini 0:9fca2b23d0ba 1487
marcozecchini 0:9fca2b23d0ba 1488 /** Create an event
marcozecchini 0:9fca2b23d0ba 1489 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1490 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1491 * @param c0,c1 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1492 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1493 * memory pool. Must be type-compatible with b0..b1, the
marcozecchini 0:9fca2b23d0ba 1494 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1495 */
marcozecchini 0:9fca2b23d0ba 1496 template <typename F, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 1497 Event(EventQueue *q, F f, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 1498 new (this) Event(q, EventQueue::context23<F, C0, C1, A0, A1, A2>(f, c0, c1));
marcozecchini 0:9fca2b23d0ba 1499 }
marcozecchini 0:9fca2b23d0ba 1500
marcozecchini 0:9fca2b23d0ba 1501 /** Create an event
marcozecchini 0:9fca2b23d0ba 1502 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1503 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1504 * @param c0,c1,c2 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1505 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1506 * memory pool. Must be type-compatible with b0..b2, the
marcozecchini 0:9fca2b23d0ba 1507 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1508 */
marcozecchini 0:9fca2b23d0ba 1509 template <typename F, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 1510 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 1511 new (this) Event(q, EventQueue::context33<F, C0, C1, C2, A0, A1, A2>(f, c0, c1, c2));
marcozecchini 0:9fca2b23d0ba 1512 }
marcozecchini 0:9fca2b23d0ba 1513
marcozecchini 0:9fca2b23d0ba 1514 /** Create an event
marcozecchini 0:9fca2b23d0ba 1515 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1516 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1517 * @param c0,c1,c2,c3 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1518 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1519 * memory pool. Must be type-compatible with b0..b3, the
marcozecchini 0:9fca2b23d0ba 1520 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1521 */
marcozecchini 0:9fca2b23d0ba 1522 template <typename F, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 1523 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 1524 new (this) Event(q, EventQueue::context43<F, C0, C1, C2, C3, A0, A1, A2>(f, c0, c1, c2, c3));
marcozecchini 0:9fca2b23d0ba 1525 }
marcozecchini 0:9fca2b23d0ba 1526
marcozecchini 0:9fca2b23d0ba 1527 /** Create an event
marcozecchini 0:9fca2b23d0ba 1528 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1529 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1530 * @param c0,c1,c2,c3,c4 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1531 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1532 * memory pool. Must be type-compatible with b0..b4, the
marcozecchini 0:9fca2b23d0ba 1533 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1534 */
marcozecchini 0:9fca2b23d0ba 1535 template <typename F, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 1536 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 1537 new (this) Event(q, EventQueue::context53<F, C0, C1, C2, C3, C4, A0, A1, A2>(f, c0, c1, c2, c3, c4));
marcozecchini 0:9fca2b23d0ba 1538 }
marcozecchini 0:9fca2b23d0ba 1539
marcozecchini 0:9fca2b23d0ba 1540 /** Create an event
marcozecchini 0:9fca2b23d0ba 1541 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1542 */
marcozecchini 0:9fca2b23d0ba 1543 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1544 Event(EventQueue *q, T *obj, R (T::*method)(B0, A0, A1, A2), B0 b0) {
marcozecchini 0:9fca2b23d0ba 1545 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1546 }
marcozecchini 0:9fca2b23d0ba 1547
marcozecchini 0:9fca2b23d0ba 1548 /** Create an event
marcozecchini 0:9fca2b23d0ba 1549 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1550 */
marcozecchini 0:9fca2b23d0ba 1551 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1552 Event(EventQueue *q, const T *obj, R (T::*method)(B0, A0, A1, A2) const, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1553 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1554 }
marcozecchini 0:9fca2b23d0ba 1555
marcozecchini 0:9fca2b23d0ba 1556 /** Create an event
marcozecchini 0:9fca2b23d0ba 1557 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1558 */
marcozecchini 0:9fca2b23d0ba 1559 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1560 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, A0, A1, A2) volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1561 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1562 }
marcozecchini 0:9fca2b23d0ba 1563
marcozecchini 0:9fca2b23d0ba 1564 /** Create an event
marcozecchini 0:9fca2b23d0ba 1565 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1566 */
marcozecchini 0:9fca2b23d0ba 1567 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1568 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, A0, A1, A2) const volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1569 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1570 }
marcozecchini 0:9fca2b23d0ba 1571
marcozecchini 0:9fca2b23d0ba 1572 /** Create an event
marcozecchini 0:9fca2b23d0ba 1573 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1574 */
marcozecchini 0:9fca2b23d0ba 1575 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1576 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, A0, A1, A2), B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1577 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1578 }
marcozecchini 0:9fca2b23d0ba 1579
marcozecchini 0:9fca2b23d0ba 1580 /** Create an event
marcozecchini 0:9fca2b23d0ba 1581 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1582 */
marcozecchini 0:9fca2b23d0ba 1583 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1584 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, A0, A1, A2) const, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1585 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1586 }
marcozecchini 0:9fca2b23d0ba 1587
marcozecchini 0:9fca2b23d0ba 1588 /** Create an event
marcozecchini 0:9fca2b23d0ba 1589 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1590 */
marcozecchini 0:9fca2b23d0ba 1591 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1592 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2) volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1593 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1594 }
marcozecchini 0:9fca2b23d0ba 1595
marcozecchini 0:9fca2b23d0ba 1596 /** Create an event
marcozecchini 0:9fca2b23d0ba 1597 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1598 */
marcozecchini 0:9fca2b23d0ba 1599 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1600 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2) const volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1601 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1602 }
marcozecchini 0:9fca2b23d0ba 1603
marcozecchini 0:9fca2b23d0ba 1604 /** Create an event
marcozecchini 0:9fca2b23d0ba 1605 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1606 */
marcozecchini 0:9fca2b23d0ba 1607 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1608 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2), B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1609 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1610 }
marcozecchini 0:9fca2b23d0ba 1611
marcozecchini 0:9fca2b23d0ba 1612 /** Create an event
marcozecchini 0:9fca2b23d0ba 1613 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1614 */
marcozecchini 0:9fca2b23d0ba 1615 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1616 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2) const, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1617 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1618 }
marcozecchini 0:9fca2b23d0ba 1619
marcozecchini 0:9fca2b23d0ba 1620 /** Create an event
marcozecchini 0:9fca2b23d0ba 1621 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1622 */
marcozecchini 0:9fca2b23d0ba 1623 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1624 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2) volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1625 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1626 }
marcozecchini 0:9fca2b23d0ba 1627
marcozecchini 0:9fca2b23d0ba 1628 /** Create an event
marcozecchini 0:9fca2b23d0ba 1629 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1630 */
marcozecchini 0:9fca2b23d0ba 1631 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 1632 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2) const volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 1633 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 1634 }
marcozecchini 0:9fca2b23d0ba 1635
marcozecchini 0:9fca2b23d0ba 1636 /** Create an event
marcozecchini 0:9fca2b23d0ba 1637 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1638 */
marcozecchini 0:9fca2b23d0ba 1639 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1640 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2), B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1641 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1642 }
marcozecchini 0:9fca2b23d0ba 1643
marcozecchini 0:9fca2b23d0ba 1644 /** Create an event
marcozecchini 0:9fca2b23d0ba 1645 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1646 */
marcozecchini 0:9fca2b23d0ba 1647 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1648 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2) const, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1649 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1650 }
marcozecchini 0:9fca2b23d0ba 1651
marcozecchini 0:9fca2b23d0ba 1652 /** Create an event
marcozecchini 0:9fca2b23d0ba 1653 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1654 */
marcozecchini 0:9fca2b23d0ba 1655 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1656 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2) volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1657 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1658 }
marcozecchini 0:9fca2b23d0ba 1659
marcozecchini 0:9fca2b23d0ba 1660 /** Create an event
marcozecchini 0:9fca2b23d0ba 1661 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1662 */
marcozecchini 0:9fca2b23d0ba 1663 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 1664 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2) const volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 1665 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 1666 }
marcozecchini 0:9fca2b23d0ba 1667
marcozecchini 0:9fca2b23d0ba 1668 /** Create an event
marcozecchini 0:9fca2b23d0ba 1669 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1670 */
marcozecchini 0:9fca2b23d0ba 1671 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1672 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2), B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1673 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1674 }
marcozecchini 0:9fca2b23d0ba 1675
marcozecchini 0:9fca2b23d0ba 1676 /** Create an event
marcozecchini 0:9fca2b23d0ba 1677 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1678 */
marcozecchini 0:9fca2b23d0ba 1679 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1680 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2) const, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1681 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1682 }
marcozecchini 0:9fca2b23d0ba 1683
marcozecchini 0:9fca2b23d0ba 1684 /** Create an event
marcozecchini 0:9fca2b23d0ba 1685 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1686 */
marcozecchini 0:9fca2b23d0ba 1687 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1688 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2) volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1689 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1690 }
marcozecchini 0:9fca2b23d0ba 1691
marcozecchini 0:9fca2b23d0ba 1692 /** Create an event
marcozecchini 0:9fca2b23d0ba 1693 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1694 */
marcozecchini 0:9fca2b23d0ba 1695 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 1696 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2) const volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 1697 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 1698 }
marcozecchini 0:9fca2b23d0ba 1699 };
marcozecchini 0:9fca2b23d0ba 1700
marcozecchini 0:9fca2b23d0ba 1701 /** Event
marcozecchini 0:9fca2b23d0ba 1702 *
marcozecchini 0:9fca2b23d0ba 1703 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 1704 * @ingroup events
marcozecchini 0:9fca2b23d0ba 1705 */
marcozecchini 0:9fca2b23d0ba 1706 template <typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 1707 class Event<void(A0, A1, A2, A3)> {
marcozecchini 0:9fca2b23d0ba 1708 public:
marcozecchini 0:9fca2b23d0ba 1709 /** Create an event
marcozecchini 0:9fca2b23d0ba 1710 *
marcozecchini 0:9fca2b23d0ba 1711 * Constructs an event bound to the specified event queue. The specified
marcozecchini 0:9fca2b23d0ba 1712 * callback acts as the target for the event and is executed in the
marcozecchini 0:9fca2b23d0ba 1713 * context of the event queue's dispatch loop once posted.
marcozecchini 0:9fca2b23d0ba 1714 *
marcozecchini 0:9fca2b23d0ba 1715 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1716 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1717 */
marcozecchini 0:9fca2b23d0ba 1718 template <typename F>
marcozecchini 0:9fca2b23d0ba 1719 Event(EventQueue *q, F f) {
marcozecchini 0:9fca2b23d0ba 1720 _event = static_cast<struct event *>(
marcozecchini 0:9fca2b23d0ba 1721 equeue_alloc(&q->_equeue, sizeof(struct event) + sizeof(F)));
marcozecchini 0:9fca2b23d0ba 1722
marcozecchini 0:9fca2b23d0ba 1723 if (_event) {
marcozecchini 0:9fca2b23d0ba 1724 _event->equeue = &q->_equeue;
marcozecchini 0:9fca2b23d0ba 1725 _event->id = 0;
marcozecchini 0:9fca2b23d0ba 1726 _event->delay = 0;
marcozecchini 0:9fca2b23d0ba 1727 _event->period = -1;
marcozecchini 0:9fca2b23d0ba 1728
marcozecchini 0:9fca2b23d0ba 1729 _event->post = &Event::event_post<F>;
marcozecchini 0:9fca2b23d0ba 1730 _event->dtor = &Event::event_dtor<F>;
marcozecchini 0:9fca2b23d0ba 1731
marcozecchini 0:9fca2b23d0ba 1732 new (_event+1) F(f);
marcozecchini 0:9fca2b23d0ba 1733
marcozecchini 0:9fca2b23d0ba 1734 _event->ref = 1;
marcozecchini 0:9fca2b23d0ba 1735 }
marcozecchini 0:9fca2b23d0ba 1736 }
marcozecchini 0:9fca2b23d0ba 1737
marcozecchini 0:9fca2b23d0ba 1738 /** Copy constructor for events
marcozecchini 0:9fca2b23d0ba 1739 */
marcozecchini 0:9fca2b23d0ba 1740 Event(const Event &e) {
marcozecchini 0:9fca2b23d0ba 1741 _event = 0;
marcozecchini 0:9fca2b23d0ba 1742 if (e._event) {
marcozecchini 0:9fca2b23d0ba 1743 _event = e._event;
marcozecchini 0:9fca2b23d0ba 1744 _event->ref += 1;
marcozecchini 0:9fca2b23d0ba 1745 }
marcozecchini 0:9fca2b23d0ba 1746 }
marcozecchini 0:9fca2b23d0ba 1747
marcozecchini 0:9fca2b23d0ba 1748 /** Assignment operator for events
marcozecchini 0:9fca2b23d0ba 1749 */
marcozecchini 0:9fca2b23d0ba 1750 Event &operator=(const Event &that) {
marcozecchini 0:9fca2b23d0ba 1751 if (this != &that) {
marcozecchini 0:9fca2b23d0ba 1752 this->~Event();
marcozecchini 0:9fca2b23d0ba 1753 new (this) Event(that);
marcozecchini 0:9fca2b23d0ba 1754 }
marcozecchini 0:9fca2b23d0ba 1755
marcozecchini 0:9fca2b23d0ba 1756 return *this;
marcozecchini 0:9fca2b23d0ba 1757 }
marcozecchini 0:9fca2b23d0ba 1758
marcozecchini 0:9fca2b23d0ba 1759 /** Destructor for events
marcozecchini 0:9fca2b23d0ba 1760 */
marcozecchini 0:9fca2b23d0ba 1761 ~Event() {
marcozecchini 0:9fca2b23d0ba 1762 if (_event) {
marcozecchini 0:9fca2b23d0ba 1763 _event->ref -= 1;
marcozecchini 0:9fca2b23d0ba 1764 if (_event->ref == 0) {
marcozecchini 0:9fca2b23d0ba 1765 _event->dtor(_event);
marcozecchini 0:9fca2b23d0ba 1766 equeue_dealloc(_event->equeue, _event);
marcozecchini 0:9fca2b23d0ba 1767 }
marcozecchini 0:9fca2b23d0ba 1768 }
marcozecchini 0:9fca2b23d0ba 1769 }
marcozecchini 0:9fca2b23d0ba 1770
marcozecchini 0:9fca2b23d0ba 1771 /** Configure the delay of an event
marcozecchini 0:9fca2b23d0ba 1772 *
marcozecchini 0:9fca2b23d0ba 1773 * @param delay Millisecond delay before dispatching the event
marcozecchini 0:9fca2b23d0ba 1774 */
marcozecchini 0:9fca2b23d0ba 1775 void delay(int delay) {
marcozecchini 0:9fca2b23d0ba 1776 if (_event) {
marcozecchini 0:9fca2b23d0ba 1777 _event->delay = delay;
marcozecchini 0:9fca2b23d0ba 1778 }
marcozecchini 0:9fca2b23d0ba 1779 }
marcozecchini 0:9fca2b23d0ba 1780
marcozecchini 0:9fca2b23d0ba 1781 /** Configure the period of an event
marcozecchini 0:9fca2b23d0ba 1782 *
marcozecchini 0:9fca2b23d0ba 1783 * @param period Millisecond period for repeatedly dispatching an event
marcozecchini 0:9fca2b23d0ba 1784 */
marcozecchini 0:9fca2b23d0ba 1785 void period(int period) {
marcozecchini 0:9fca2b23d0ba 1786 if (_event) {
marcozecchini 0:9fca2b23d0ba 1787 _event->period = period;
marcozecchini 0:9fca2b23d0ba 1788 }
marcozecchini 0:9fca2b23d0ba 1789 }
marcozecchini 0:9fca2b23d0ba 1790
marcozecchini 0:9fca2b23d0ba 1791 /** Posts an event onto the underlying event queue
marcozecchini 0:9fca2b23d0ba 1792 *
marcozecchini 0:9fca2b23d0ba 1793 * The event is posted to the underlying queue and is executed in the
marcozecchini 0:9fca2b23d0ba 1794 * context of the event queue's dispatch loop.
marcozecchini 0:9fca2b23d0ba 1795 *
marcozecchini 0:9fca2b23d0ba 1796 * The post function is irq safe and can act as a mechanism for moving
marcozecchini 0:9fca2b23d0ba 1797 * events out of irq contexts.
marcozecchini 0:9fca2b23d0ba 1798 *
marcozecchini 0:9fca2b23d0ba 1799 * @param a0,a1,a2,a3 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1800 * @return A unique id that represents the posted event and can
marcozecchini 0:9fca2b23d0ba 1801 * be passed to EventQueue::cancel, or an id of 0 if
marcozecchini 0:9fca2b23d0ba 1802 * there is not enough memory to allocate the event.
marcozecchini 0:9fca2b23d0ba 1803 */
marcozecchini 0:9fca2b23d0ba 1804 int post(A0 a0, A1 a1, A2 a2, A3 a3) const {
marcozecchini 0:9fca2b23d0ba 1805 if (!_event) {
marcozecchini 0:9fca2b23d0ba 1806 return 0;
marcozecchini 0:9fca2b23d0ba 1807 }
marcozecchini 0:9fca2b23d0ba 1808
marcozecchini 0:9fca2b23d0ba 1809 _event->id = _event->post(_event, a0, a1, a2, a3);
marcozecchini 0:9fca2b23d0ba 1810 return _event->id;
marcozecchini 0:9fca2b23d0ba 1811 }
marcozecchini 0:9fca2b23d0ba 1812
marcozecchini 0:9fca2b23d0ba 1813 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 1814 *
marcozecchini 0:9fca2b23d0ba 1815 * @param a0,a1,a2,a3 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1816 */
marcozecchini 0:9fca2b23d0ba 1817 void call(A0 a0, A1 a1, A2 a2, A3 a3) const {
marcozecchini 0:9fca2b23d0ba 1818 MBED_UNUSED int id = post(a0, a1, a2, a3);
marcozecchini 0:9fca2b23d0ba 1819 MBED_ASSERT(id);
marcozecchini 0:9fca2b23d0ba 1820 }
marcozecchini 0:9fca2b23d0ba 1821
marcozecchini 0:9fca2b23d0ba 1822 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 1823 *
marcozecchini 0:9fca2b23d0ba 1824 * @param a0,a1,a2,a3 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1825 */
marcozecchini 0:9fca2b23d0ba 1826 void operator()(A0 a0, A1 a1, A2 a2, A3 a3) const {
marcozecchini 0:9fca2b23d0ba 1827 return call(a0, a1, a2, a3);
marcozecchini 0:9fca2b23d0ba 1828 }
marcozecchini 0:9fca2b23d0ba 1829
marcozecchini 0:9fca2b23d0ba 1830 /** Static thunk for passing as C-style function
marcozecchini 0:9fca2b23d0ba 1831 *
marcozecchini 0:9fca2b23d0ba 1832 * @param func Event to call passed as a void pointer
marcozecchini 0:9fca2b23d0ba 1833 * @param a0,a1,a2,a3 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 1834 */
marcozecchini 0:9fca2b23d0ba 1835 static void thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3) {
marcozecchini 0:9fca2b23d0ba 1836 return static_cast<Event*>(func)->call(a0, a1, a2, a3);
marcozecchini 0:9fca2b23d0ba 1837 }
marcozecchini 0:9fca2b23d0ba 1838
marcozecchini 0:9fca2b23d0ba 1839 /** Cancels the most recently posted event
marcozecchini 0:9fca2b23d0ba 1840 *
marcozecchini 0:9fca2b23d0ba 1841 * Attempts to cancel the most recently posted event. It is safe to call
marcozecchini 0:9fca2b23d0ba 1842 * cancel after an event has already been dispatched.
marcozecchini 0:9fca2b23d0ba 1843 *
marcozecchini 0:9fca2b23d0ba 1844 * The cancel function is irq safe.
marcozecchini 0:9fca2b23d0ba 1845 *
marcozecchini 0:9fca2b23d0ba 1846 * If called while the event queue's dispatch loop is active, the cancel
marcozecchini 0:9fca2b23d0ba 1847 * function does not garuntee that the event will not execute after it
marcozecchini 0:9fca2b23d0ba 1848 * returns, as the event may have already begun executing.
marcozecchini 0:9fca2b23d0ba 1849 */
marcozecchini 0:9fca2b23d0ba 1850 void cancel() const {
marcozecchini 0:9fca2b23d0ba 1851 if (_event) {
marcozecchini 0:9fca2b23d0ba 1852 equeue_cancel(_event->equeue, _event->id);
marcozecchini 0:9fca2b23d0ba 1853 }
marcozecchini 0:9fca2b23d0ba 1854 }
marcozecchini 0:9fca2b23d0ba 1855
marcozecchini 0:9fca2b23d0ba 1856 private:
marcozecchini 0:9fca2b23d0ba 1857 struct event {
marcozecchini 0:9fca2b23d0ba 1858 unsigned ref;
marcozecchini 0:9fca2b23d0ba 1859 equeue_t *equeue;
marcozecchini 0:9fca2b23d0ba 1860 int id;
marcozecchini 0:9fca2b23d0ba 1861
marcozecchini 0:9fca2b23d0ba 1862 int delay;
marcozecchini 0:9fca2b23d0ba 1863 int period;
marcozecchini 0:9fca2b23d0ba 1864
marcozecchini 0:9fca2b23d0ba 1865 int (*post)(struct event *, A0 a0, A1 a1, A2 a2, A3 a3);
marcozecchini 0:9fca2b23d0ba 1866 void (*dtor)(struct event *);
marcozecchini 0:9fca2b23d0ba 1867
marcozecchini 0:9fca2b23d0ba 1868 // F follows
marcozecchini 0:9fca2b23d0ba 1869 } *_event;
marcozecchini 0:9fca2b23d0ba 1870
marcozecchini 0:9fca2b23d0ba 1871 // Event attributes
marcozecchini 0:9fca2b23d0ba 1872 template <typename F>
marcozecchini 0:9fca2b23d0ba 1873 static int event_post(struct event *e, A0 a0, A1 a1, A2 a2, A3 a3) {
marcozecchini 0:9fca2b23d0ba 1874 typedef EventQueue::context40<F, A0, A1, A2, A3> C;
marcozecchini 0:9fca2b23d0ba 1875 void *p = equeue_alloc(e->equeue, sizeof(C));
marcozecchini 0:9fca2b23d0ba 1876 if (!p) {
marcozecchini 0:9fca2b23d0ba 1877 return 0;
marcozecchini 0:9fca2b23d0ba 1878 }
marcozecchini 0:9fca2b23d0ba 1879
marcozecchini 0:9fca2b23d0ba 1880 new (p) C(*(F*)(e + 1), a0, a1, a2, a3);
marcozecchini 0:9fca2b23d0ba 1881 equeue_event_delay(p, e->delay);
marcozecchini 0:9fca2b23d0ba 1882 equeue_event_period(p, e->period);
marcozecchini 0:9fca2b23d0ba 1883 equeue_event_dtor(p, &EventQueue::function_dtor<C>);
marcozecchini 0:9fca2b23d0ba 1884 return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
marcozecchini 0:9fca2b23d0ba 1885 }
marcozecchini 0:9fca2b23d0ba 1886
marcozecchini 0:9fca2b23d0ba 1887 template <typename F>
marcozecchini 0:9fca2b23d0ba 1888 static void event_dtor(struct event *e) {
marcozecchini 0:9fca2b23d0ba 1889 ((F*)(e + 1))->~F();
marcozecchini 0:9fca2b23d0ba 1890 }
marcozecchini 0:9fca2b23d0ba 1891
marcozecchini 0:9fca2b23d0ba 1892 public:
marcozecchini 0:9fca2b23d0ba 1893 /** Create an event
marcozecchini 0:9fca2b23d0ba 1894 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1895 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1896 * @param c0 Argument to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1897 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1898 * memory pool. Must be type-compatible with b0, the
marcozecchini 0:9fca2b23d0ba 1899 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1900 */
marcozecchini 0:9fca2b23d0ba 1901 template <typename F, typename C0>
marcozecchini 0:9fca2b23d0ba 1902 Event(EventQueue *q, F f, C0 c0) {
marcozecchini 0:9fca2b23d0ba 1903 new (this) Event(q, EventQueue::context14<F, C0, A0, A1, A2, A3>(f, c0));
marcozecchini 0:9fca2b23d0ba 1904 }
marcozecchini 0:9fca2b23d0ba 1905
marcozecchini 0:9fca2b23d0ba 1906 /** Create an event
marcozecchini 0:9fca2b23d0ba 1907 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1908 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1909 * @param c0,c1 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1910 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1911 * memory pool. Must be type-compatible with b0..b1, the
marcozecchini 0:9fca2b23d0ba 1912 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1913 */
marcozecchini 0:9fca2b23d0ba 1914 template <typename F, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 1915 Event(EventQueue *q, F f, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 1916 new (this) Event(q, EventQueue::context24<F, C0, C1, A0, A1, A2, A3>(f, c0, c1));
marcozecchini 0:9fca2b23d0ba 1917 }
marcozecchini 0:9fca2b23d0ba 1918
marcozecchini 0:9fca2b23d0ba 1919 /** Create an event
marcozecchini 0:9fca2b23d0ba 1920 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1921 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1922 * @param c0,c1,c2 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1923 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1924 * memory pool. Must be type-compatible with b0..b2, the
marcozecchini 0:9fca2b23d0ba 1925 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1926 */
marcozecchini 0:9fca2b23d0ba 1927 template <typename F, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 1928 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 1929 new (this) Event(q, EventQueue::context34<F, C0, C1, C2, A0, A1, A2, A3>(f, c0, c1, c2));
marcozecchini 0:9fca2b23d0ba 1930 }
marcozecchini 0:9fca2b23d0ba 1931
marcozecchini 0:9fca2b23d0ba 1932 /** Create an event
marcozecchini 0:9fca2b23d0ba 1933 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1934 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1935 * @param c0,c1,c2,c3 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1936 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1937 * memory pool. Must be type-compatible with b0..b3, the
marcozecchini 0:9fca2b23d0ba 1938 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1939 */
marcozecchini 0:9fca2b23d0ba 1940 template <typename F, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 1941 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 1942 new (this) Event(q, EventQueue::context44<F, C0, C1, C2, C3, A0, A1, A2, A3>(f, c0, c1, c2, c3));
marcozecchini 0:9fca2b23d0ba 1943 }
marcozecchini 0:9fca2b23d0ba 1944
marcozecchini 0:9fca2b23d0ba 1945 /** Create an event
marcozecchini 0:9fca2b23d0ba 1946 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 1947 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 1948 * @param c0,c1,c2,c3,c4 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 1949 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 1950 * memory pool. Must be type-compatible with b0..b4, the
marcozecchini 0:9fca2b23d0ba 1951 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 1952 */
marcozecchini 0:9fca2b23d0ba 1953 template <typename F, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 1954 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 1955 new (this) Event(q, EventQueue::context54<F, C0, C1, C2, C3, C4, A0, A1, A2, A3>(f, c0, c1, c2, c3, c4));
marcozecchini 0:9fca2b23d0ba 1956 }
marcozecchini 0:9fca2b23d0ba 1957
marcozecchini 0:9fca2b23d0ba 1958 /** Create an event
marcozecchini 0:9fca2b23d0ba 1959 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1960 */
marcozecchini 0:9fca2b23d0ba 1961 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1962 Event(EventQueue *q, T *obj, R (T::*method)(B0, A0, A1, A2, A3), B0 b0) {
marcozecchini 0:9fca2b23d0ba 1963 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1964 }
marcozecchini 0:9fca2b23d0ba 1965
marcozecchini 0:9fca2b23d0ba 1966 /** Create an event
marcozecchini 0:9fca2b23d0ba 1967 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1968 */
marcozecchini 0:9fca2b23d0ba 1969 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1970 Event(EventQueue *q, const T *obj, R (T::*method)(B0, A0, A1, A2, A3) const, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1971 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1972 }
marcozecchini 0:9fca2b23d0ba 1973
marcozecchini 0:9fca2b23d0ba 1974 /** Create an event
marcozecchini 0:9fca2b23d0ba 1975 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1976 */
marcozecchini 0:9fca2b23d0ba 1977 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1978 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3) volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1979 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1980 }
marcozecchini 0:9fca2b23d0ba 1981
marcozecchini 0:9fca2b23d0ba 1982 /** Create an event
marcozecchini 0:9fca2b23d0ba 1983 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1984 */
marcozecchini 0:9fca2b23d0ba 1985 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 1986 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3) const volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 1987 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 1988 }
marcozecchini 0:9fca2b23d0ba 1989
marcozecchini 0:9fca2b23d0ba 1990 /** Create an event
marcozecchini 0:9fca2b23d0ba 1991 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 1992 */
marcozecchini 0:9fca2b23d0ba 1993 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 1994 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3), B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 1995 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 1996 }
marcozecchini 0:9fca2b23d0ba 1997
marcozecchini 0:9fca2b23d0ba 1998 /** Create an event
marcozecchini 0:9fca2b23d0ba 1999 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2000 */
marcozecchini 0:9fca2b23d0ba 2001 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2002 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3) const, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2003 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2004 }
marcozecchini 0:9fca2b23d0ba 2005
marcozecchini 0:9fca2b23d0ba 2006 /** Create an event
marcozecchini 0:9fca2b23d0ba 2007 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2008 */
marcozecchini 0:9fca2b23d0ba 2009 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2010 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3) volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2011 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2012 }
marcozecchini 0:9fca2b23d0ba 2013
marcozecchini 0:9fca2b23d0ba 2014 /** Create an event
marcozecchini 0:9fca2b23d0ba 2015 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2016 */
marcozecchini 0:9fca2b23d0ba 2017 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2018 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3) const volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2019 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2020 }
marcozecchini 0:9fca2b23d0ba 2021
marcozecchini 0:9fca2b23d0ba 2022 /** Create an event
marcozecchini 0:9fca2b23d0ba 2023 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2024 */
marcozecchini 0:9fca2b23d0ba 2025 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2026 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3), B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2027 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2028 }
marcozecchini 0:9fca2b23d0ba 2029
marcozecchini 0:9fca2b23d0ba 2030 /** Create an event
marcozecchini 0:9fca2b23d0ba 2031 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2032 */
marcozecchini 0:9fca2b23d0ba 2033 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2034 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3) const, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2035 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2036 }
marcozecchini 0:9fca2b23d0ba 2037
marcozecchini 0:9fca2b23d0ba 2038 /** Create an event
marcozecchini 0:9fca2b23d0ba 2039 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2040 */
marcozecchini 0:9fca2b23d0ba 2041 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2042 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3) volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2043 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2044 }
marcozecchini 0:9fca2b23d0ba 2045
marcozecchini 0:9fca2b23d0ba 2046 /** Create an event
marcozecchini 0:9fca2b23d0ba 2047 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2048 */
marcozecchini 0:9fca2b23d0ba 2049 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2050 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3) const volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2051 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2052 }
marcozecchini 0:9fca2b23d0ba 2053
marcozecchini 0:9fca2b23d0ba 2054 /** Create an event
marcozecchini 0:9fca2b23d0ba 2055 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2056 */
marcozecchini 0:9fca2b23d0ba 2057 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2058 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3), B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2059 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2060 }
marcozecchini 0:9fca2b23d0ba 2061
marcozecchini 0:9fca2b23d0ba 2062 /** Create an event
marcozecchini 0:9fca2b23d0ba 2063 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2064 */
marcozecchini 0:9fca2b23d0ba 2065 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2066 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3) const, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2067 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2068 }
marcozecchini 0:9fca2b23d0ba 2069
marcozecchini 0:9fca2b23d0ba 2070 /** Create an event
marcozecchini 0:9fca2b23d0ba 2071 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2072 */
marcozecchini 0:9fca2b23d0ba 2073 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2074 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3) volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2075 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2076 }
marcozecchini 0:9fca2b23d0ba 2077
marcozecchini 0:9fca2b23d0ba 2078 /** Create an event
marcozecchini 0:9fca2b23d0ba 2079 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2080 */
marcozecchini 0:9fca2b23d0ba 2081 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2082 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3) const volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2083 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2084 }
marcozecchini 0:9fca2b23d0ba 2085
marcozecchini 0:9fca2b23d0ba 2086 /** Create an event
marcozecchini 0:9fca2b23d0ba 2087 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2088 */
marcozecchini 0:9fca2b23d0ba 2089 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2090 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3), B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2091 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2092 }
marcozecchini 0:9fca2b23d0ba 2093
marcozecchini 0:9fca2b23d0ba 2094 /** Create an event
marcozecchini 0:9fca2b23d0ba 2095 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2096 */
marcozecchini 0:9fca2b23d0ba 2097 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2098 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3) const, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2099 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2100 }
marcozecchini 0:9fca2b23d0ba 2101
marcozecchini 0:9fca2b23d0ba 2102 /** Create an event
marcozecchini 0:9fca2b23d0ba 2103 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2104 */
marcozecchini 0:9fca2b23d0ba 2105 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2106 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3) volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2107 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2108 }
marcozecchini 0:9fca2b23d0ba 2109
marcozecchini 0:9fca2b23d0ba 2110 /** Create an event
marcozecchini 0:9fca2b23d0ba 2111 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2112 */
marcozecchini 0:9fca2b23d0ba 2113 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2114 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3) const volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2115 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2116 }
marcozecchini 0:9fca2b23d0ba 2117 };
marcozecchini 0:9fca2b23d0ba 2118
marcozecchini 0:9fca2b23d0ba 2119 /** Event
marcozecchini 0:9fca2b23d0ba 2120 *
marcozecchini 0:9fca2b23d0ba 2121 * Representation of an event for fine-grain dispatch control
marcozecchini 0:9fca2b23d0ba 2122 * @ingroup events
marcozecchini 0:9fca2b23d0ba 2123 */
marcozecchini 0:9fca2b23d0ba 2124 template <typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 2125 class Event<void(A0, A1, A2, A3, A4)> {
marcozecchini 0:9fca2b23d0ba 2126 public:
marcozecchini 0:9fca2b23d0ba 2127 /** Create an event
marcozecchini 0:9fca2b23d0ba 2128 *
marcozecchini 0:9fca2b23d0ba 2129 * Constructs an event bound to the specified event queue. The specified
marcozecchini 0:9fca2b23d0ba 2130 * callback acts as the target for the event and is executed in the
marcozecchini 0:9fca2b23d0ba 2131 * context of the event queue's dispatch loop once posted.
marcozecchini 0:9fca2b23d0ba 2132 *
marcozecchini 0:9fca2b23d0ba 2133 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 2134 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 2135 */
marcozecchini 0:9fca2b23d0ba 2136 template <typename F>
marcozecchini 0:9fca2b23d0ba 2137 Event(EventQueue *q, F f) {
marcozecchini 0:9fca2b23d0ba 2138 _event = static_cast<struct event *>(
marcozecchini 0:9fca2b23d0ba 2139 equeue_alloc(&q->_equeue, sizeof(struct event) + sizeof(F)));
marcozecchini 0:9fca2b23d0ba 2140
marcozecchini 0:9fca2b23d0ba 2141 if (_event) {
marcozecchini 0:9fca2b23d0ba 2142 _event->equeue = &q->_equeue;
marcozecchini 0:9fca2b23d0ba 2143 _event->id = 0;
marcozecchini 0:9fca2b23d0ba 2144 _event->delay = 0;
marcozecchini 0:9fca2b23d0ba 2145 _event->period = -1;
marcozecchini 0:9fca2b23d0ba 2146
marcozecchini 0:9fca2b23d0ba 2147 _event->post = &Event::event_post<F>;
marcozecchini 0:9fca2b23d0ba 2148 _event->dtor = &Event::event_dtor<F>;
marcozecchini 0:9fca2b23d0ba 2149
marcozecchini 0:9fca2b23d0ba 2150 new (_event+1) F(f);
marcozecchini 0:9fca2b23d0ba 2151
marcozecchini 0:9fca2b23d0ba 2152 _event->ref = 1;
marcozecchini 0:9fca2b23d0ba 2153 }
marcozecchini 0:9fca2b23d0ba 2154 }
marcozecchini 0:9fca2b23d0ba 2155
marcozecchini 0:9fca2b23d0ba 2156 /** Copy constructor for events
marcozecchini 0:9fca2b23d0ba 2157 */
marcozecchini 0:9fca2b23d0ba 2158 Event(const Event &e) {
marcozecchini 0:9fca2b23d0ba 2159 _event = 0;
marcozecchini 0:9fca2b23d0ba 2160 if (e._event) {
marcozecchini 0:9fca2b23d0ba 2161 _event = e._event;
marcozecchini 0:9fca2b23d0ba 2162 _event->ref += 1;
marcozecchini 0:9fca2b23d0ba 2163 }
marcozecchini 0:9fca2b23d0ba 2164 }
marcozecchini 0:9fca2b23d0ba 2165
marcozecchini 0:9fca2b23d0ba 2166 /** Assignment operator for events
marcozecchini 0:9fca2b23d0ba 2167 */
marcozecchini 0:9fca2b23d0ba 2168 Event &operator=(const Event &that) {
marcozecchini 0:9fca2b23d0ba 2169 if (this != &that) {
marcozecchini 0:9fca2b23d0ba 2170 this->~Event();
marcozecchini 0:9fca2b23d0ba 2171 new (this) Event(that);
marcozecchini 0:9fca2b23d0ba 2172 }
marcozecchini 0:9fca2b23d0ba 2173
marcozecchini 0:9fca2b23d0ba 2174 return *this;
marcozecchini 0:9fca2b23d0ba 2175 }
marcozecchini 0:9fca2b23d0ba 2176
marcozecchini 0:9fca2b23d0ba 2177 /** Destructor for events
marcozecchini 0:9fca2b23d0ba 2178 */
marcozecchini 0:9fca2b23d0ba 2179 ~Event() {
marcozecchini 0:9fca2b23d0ba 2180 if (_event) {
marcozecchini 0:9fca2b23d0ba 2181 _event->ref -= 1;
marcozecchini 0:9fca2b23d0ba 2182 if (_event->ref == 0) {
marcozecchini 0:9fca2b23d0ba 2183 _event->dtor(_event);
marcozecchini 0:9fca2b23d0ba 2184 equeue_dealloc(_event->equeue, _event);
marcozecchini 0:9fca2b23d0ba 2185 }
marcozecchini 0:9fca2b23d0ba 2186 }
marcozecchini 0:9fca2b23d0ba 2187 }
marcozecchini 0:9fca2b23d0ba 2188
marcozecchini 0:9fca2b23d0ba 2189 /** Configure the delay of an event
marcozecchini 0:9fca2b23d0ba 2190 *
marcozecchini 0:9fca2b23d0ba 2191 * @param delay Millisecond delay before dispatching the event
marcozecchini 0:9fca2b23d0ba 2192 */
marcozecchini 0:9fca2b23d0ba 2193 void delay(int delay) {
marcozecchini 0:9fca2b23d0ba 2194 if (_event) {
marcozecchini 0:9fca2b23d0ba 2195 _event->delay = delay;
marcozecchini 0:9fca2b23d0ba 2196 }
marcozecchini 0:9fca2b23d0ba 2197 }
marcozecchini 0:9fca2b23d0ba 2198
marcozecchini 0:9fca2b23d0ba 2199 /** Configure the period of an event
marcozecchini 0:9fca2b23d0ba 2200 *
marcozecchini 0:9fca2b23d0ba 2201 * @param period Millisecond period for repeatedly dispatching an event
marcozecchini 0:9fca2b23d0ba 2202 */
marcozecchini 0:9fca2b23d0ba 2203 void period(int period) {
marcozecchini 0:9fca2b23d0ba 2204 if (_event) {
marcozecchini 0:9fca2b23d0ba 2205 _event->period = period;
marcozecchini 0:9fca2b23d0ba 2206 }
marcozecchini 0:9fca2b23d0ba 2207 }
marcozecchini 0:9fca2b23d0ba 2208
marcozecchini 0:9fca2b23d0ba 2209 /** Posts an event onto the underlying event queue
marcozecchini 0:9fca2b23d0ba 2210 *
marcozecchini 0:9fca2b23d0ba 2211 * The event is posted to the underlying queue and is executed in the
marcozecchini 0:9fca2b23d0ba 2212 * context of the event queue's dispatch loop.
marcozecchini 0:9fca2b23d0ba 2213 *
marcozecchini 0:9fca2b23d0ba 2214 * The post function is irq safe and can act as a mechanism for moving
marcozecchini 0:9fca2b23d0ba 2215 * events out of irq contexts.
marcozecchini 0:9fca2b23d0ba 2216 *
marcozecchini 0:9fca2b23d0ba 2217 * @param a0,a1,a2,a3,a4 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 2218 * @return A unique id that represents the posted event and can
marcozecchini 0:9fca2b23d0ba 2219 * be passed to EventQueue::cancel, or an id of 0 if
marcozecchini 0:9fca2b23d0ba 2220 * there is not enough memory to allocate the event.
marcozecchini 0:9fca2b23d0ba 2221 */
marcozecchini 0:9fca2b23d0ba 2222 int post(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
marcozecchini 0:9fca2b23d0ba 2223 if (!_event) {
marcozecchini 0:9fca2b23d0ba 2224 return 0;
marcozecchini 0:9fca2b23d0ba 2225 }
marcozecchini 0:9fca2b23d0ba 2226
marcozecchini 0:9fca2b23d0ba 2227 _event->id = _event->post(_event, a0, a1, a2, a3, a4);
marcozecchini 0:9fca2b23d0ba 2228 return _event->id;
marcozecchini 0:9fca2b23d0ba 2229 }
marcozecchini 0:9fca2b23d0ba 2230
marcozecchini 0:9fca2b23d0ba 2231 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 2232 *
marcozecchini 0:9fca2b23d0ba 2233 * @param a0,a1,a2,a3,a4 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 2234 */
marcozecchini 0:9fca2b23d0ba 2235 void call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
marcozecchini 0:9fca2b23d0ba 2236 MBED_UNUSED int id = post(a0, a1, a2, a3, a4);
marcozecchini 0:9fca2b23d0ba 2237 MBED_ASSERT(id);
marcozecchini 0:9fca2b23d0ba 2238 }
marcozecchini 0:9fca2b23d0ba 2239
marcozecchini 0:9fca2b23d0ba 2240 /** Posts an event onto the underlying event queue, returning void
marcozecchini 0:9fca2b23d0ba 2241 *
marcozecchini 0:9fca2b23d0ba 2242 * @param a0,a1,a2,a3,a4 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 2243 */
marcozecchini 0:9fca2b23d0ba 2244 void operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
marcozecchini 0:9fca2b23d0ba 2245 return call(a0, a1, a2, a3, a4);
marcozecchini 0:9fca2b23d0ba 2246 }
marcozecchini 0:9fca2b23d0ba 2247
marcozecchini 0:9fca2b23d0ba 2248 /** Static thunk for passing as C-style function
marcozecchini 0:9fca2b23d0ba 2249 *
marcozecchini 0:9fca2b23d0ba 2250 * @param func Event to call passed as a void pointer
marcozecchini 0:9fca2b23d0ba 2251 * @param a0,a1,a2,a3,a4 Arguments to pass to the event
marcozecchini 0:9fca2b23d0ba 2252 */
marcozecchini 0:9fca2b23d0ba 2253 static void thunk(void *func, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
marcozecchini 0:9fca2b23d0ba 2254 return static_cast<Event*>(func)->call(a0, a1, a2, a3, a4);
marcozecchini 0:9fca2b23d0ba 2255 }
marcozecchini 0:9fca2b23d0ba 2256
marcozecchini 0:9fca2b23d0ba 2257 /** Cancels the most recently posted event
marcozecchini 0:9fca2b23d0ba 2258 *
marcozecchini 0:9fca2b23d0ba 2259 * Attempts to cancel the most recently posted event. It is safe to call
marcozecchini 0:9fca2b23d0ba 2260 * cancel after an event has already been dispatched.
marcozecchini 0:9fca2b23d0ba 2261 *
marcozecchini 0:9fca2b23d0ba 2262 * The cancel function is irq safe.
marcozecchini 0:9fca2b23d0ba 2263 *
marcozecchini 0:9fca2b23d0ba 2264 * If called while the event queue's dispatch loop is active, the cancel
marcozecchini 0:9fca2b23d0ba 2265 * function does not garuntee that the event will not execute after it
marcozecchini 0:9fca2b23d0ba 2266 * returns, as the event may have already begun executing.
marcozecchini 0:9fca2b23d0ba 2267 */
marcozecchini 0:9fca2b23d0ba 2268 void cancel() const {
marcozecchini 0:9fca2b23d0ba 2269 if (_event) {
marcozecchini 0:9fca2b23d0ba 2270 equeue_cancel(_event->equeue, _event->id);
marcozecchini 0:9fca2b23d0ba 2271 }
marcozecchini 0:9fca2b23d0ba 2272 }
marcozecchini 0:9fca2b23d0ba 2273
marcozecchini 0:9fca2b23d0ba 2274 private:
marcozecchini 0:9fca2b23d0ba 2275 struct event {
marcozecchini 0:9fca2b23d0ba 2276 unsigned ref;
marcozecchini 0:9fca2b23d0ba 2277 equeue_t *equeue;
marcozecchini 0:9fca2b23d0ba 2278 int id;
marcozecchini 0:9fca2b23d0ba 2279
marcozecchini 0:9fca2b23d0ba 2280 int delay;
marcozecchini 0:9fca2b23d0ba 2281 int period;
marcozecchini 0:9fca2b23d0ba 2282
marcozecchini 0:9fca2b23d0ba 2283 int (*post)(struct event *, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4);
marcozecchini 0:9fca2b23d0ba 2284 void (*dtor)(struct event *);
marcozecchini 0:9fca2b23d0ba 2285
marcozecchini 0:9fca2b23d0ba 2286 // F follows
marcozecchini 0:9fca2b23d0ba 2287 } *_event;
marcozecchini 0:9fca2b23d0ba 2288
marcozecchini 0:9fca2b23d0ba 2289 // Event attributes
marcozecchini 0:9fca2b23d0ba 2290 template <typename F>
marcozecchini 0:9fca2b23d0ba 2291 static int event_post(struct event *e, A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
marcozecchini 0:9fca2b23d0ba 2292 typedef EventQueue::context50<F, A0, A1, A2, A3, A4> C;
marcozecchini 0:9fca2b23d0ba 2293 void *p = equeue_alloc(e->equeue, sizeof(C));
marcozecchini 0:9fca2b23d0ba 2294 if (!p) {
marcozecchini 0:9fca2b23d0ba 2295 return 0;
marcozecchini 0:9fca2b23d0ba 2296 }
marcozecchini 0:9fca2b23d0ba 2297
marcozecchini 0:9fca2b23d0ba 2298 new (p) C(*(F*)(e + 1), a0, a1, a2, a3, a4);
marcozecchini 0:9fca2b23d0ba 2299 equeue_event_delay(p, e->delay);
marcozecchini 0:9fca2b23d0ba 2300 equeue_event_period(p, e->period);
marcozecchini 0:9fca2b23d0ba 2301 equeue_event_dtor(p, &EventQueue::function_dtor<C>);
marcozecchini 0:9fca2b23d0ba 2302 return equeue_post(e->equeue, &EventQueue::function_call<C>, p);
marcozecchini 0:9fca2b23d0ba 2303 }
marcozecchini 0:9fca2b23d0ba 2304
marcozecchini 0:9fca2b23d0ba 2305 template <typename F>
marcozecchini 0:9fca2b23d0ba 2306 static void event_dtor(struct event *e) {
marcozecchini 0:9fca2b23d0ba 2307 ((F*)(e + 1))->~F();
marcozecchini 0:9fca2b23d0ba 2308 }
marcozecchini 0:9fca2b23d0ba 2309
marcozecchini 0:9fca2b23d0ba 2310 public:
marcozecchini 0:9fca2b23d0ba 2311 /** Create an event
marcozecchini 0:9fca2b23d0ba 2312 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 2313 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 2314 * @param c0 Argument to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 2315 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 2316 * memory pool. Must be type-compatible with b0, the
marcozecchini 0:9fca2b23d0ba 2317 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 2318 */
marcozecchini 0:9fca2b23d0ba 2319 template <typename F, typename C0>
marcozecchini 0:9fca2b23d0ba 2320 Event(EventQueue *q, F f, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2321 new (this) Event(q, EventQueue::context15<F, C0, A0, A1, A2, A3, A4>(f, c0));
marcozecchini 0:9fca2b23d0ba 2322 }
marcozecchini 0:9fca2b23d0ba 2323
marcozecchini 0:9fca2b23d0ba 2324 /** Create an event
marcozecchini 0:9fca2b23d0ba 2325 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 2326 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 2327 * @param c0,c1 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 2328 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 2329 * memory pool. Must be type-compatible with b0..b1, the
marcozecchini 0:9fca2b23d0ba 2330 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 2331 */
marcozecchini 0:9fca2b23d0ba 2332 template <typename F, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2333 Event(EventQueue *q, F f, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2334 new (this) Event(q, EventQueue::context25<F, C0, C1, A0, A1, A2, A3, A4>(f, c0, c1));
marcozecchini 0:9fca2b23d0ba 2335 }
marcozecchini 0:9fca2b23d0ba 2336
marcozecchini 0:9fca2b23d0ba 2337 /** Create an event
marcozecchini 0:9fca2b23d0ba 2338 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 2339 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 2340 * @param c0,c1,c2 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 2341 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 2342 * memory pool. Must be type-compatible with b0..b2, the
marcozecchini 0:9fca2b23d0ba 2343 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 2344 */
marcozecchini 0:9fca2b23d0ba 2345 template <typename F, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2346 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2347 new (this) Event(q, EventQueue::context35<F, C0, C1, C2, A0, A1, A2, A3, A4>(f, c0, c1, c2));
marcozecchini 0:9fca2b23d0ba 2348 }
marcozecchini 0:9fca2b23d0ba 2349
marcozecchini 0:9fca2b23d0ba 2350 /** Create an event
marcozecchini 0:9fca2b23d0ba 2351 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 2352 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 2353 * @param c0,c1,c2,c3 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 2354 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 2355 * memory pool. Must be type-compatible with b0..b3, the
marcozecchini 0:9fca2b23d0ba 2356 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 2357 */
marcozecchini 0:9fca2b23d0ba 2358 template <typename F, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2359 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2360 new (this) Event(q, EventQueue::context45<F, C0, C1, C2, C3, A0, A1, A2, A3, A4>(f, c0, c1, c2, c3));
marcozecchini 0:9fca2b23d0ba 2361 }
marcozecchini 0:9fca2b23d0ba 2362
marcozecchini 0:9fca2b23d0ba 2363 /** Create an event
marcozecchini 0:9fca2b23d0ba 2364 * @param q Event queue to dispatch on
marcozecchini 0:9fca2b23d0ba 2365 * @param f Function to execute when the event is dispatched
marcozecchini 0:9fca2b23d0ba 2366 * @param c0,c1,c2,c3,c4 Arguments to bind to the callback, these arguments are
marcozecchini 0:9fca2b23d0ba 2367 * allocated on an irq-safe allocator from the event queue's
marcozecchini 0:9fca2b23d0ba 2368 * memory pool. Must be type-compatible with b0..b4, the
marcozecchini 0:9fca2b23d0ba 2369 * arguments to the underlying callback.
marcozecchini 0:9fca2b23d0ba 2370 */
marcozecchini 0:9fca2b23d0ba 2371 template <typename F, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2372 Event(EventQueue *q, F f, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2373 new (this) Event(q, EventQueue::context55<F, C0, C1, C2, C3, C4, A0, A1, A2, A3, A4>(f, c0, c1, c2, c3, c4));
marcozecchini 0:9fca2b23d0ba 2374 }
marcozecchini 0:9fca2b23d0ba 2375
marcozecchini 0:9fca2b23d0ba 2376 /** Create an event
marcozecchini 0:9fca2b23d0ba 2377 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2378 */
marcozecchini 0:9fca2b23d0ba 2379 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 2380 Event(EventQueue *q, T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4), B0 b0) {
marcozecchini 0:9fca2b23d0ba 2381 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 2382 }
marcozecchini 0:9fca2b23d0ba 2383
marcozecchini 0:9fca2b23d0ba 2384 /** Create an event
marcozecchini 0:9fca2b23d0ba 2385 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2386 */
marcozecchini 0:9fca2b23d0ba 2387 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 2388 Event(EventQueue *q, const T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4) const, B0 b0) {
marcozecchini 0:9fca2b23d0ba 2389 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 2390 }
marcozecchini 0:9fca2b23d0ba 2391
marcozecchini 0:9fca2b23d0ba 2392 /** Create an event
marcozecchini 0:9fca2b23d0ba 2393 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2394 */
marcozecchini 0:9fca2b23d0ba 2395 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 2396 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4) volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 2397 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 2398 }
marcozecchini 0:9fca2b23d0ba 2399
marcozecchini 0:9fca2b23d0ba 2400 /** Create an event
marcozecchini 0:9fca2b23d0ba 2401 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2402 */
marcozecchini 0:9fca2b23d0ba 2403 template <typename T, typename R, typename B0>
marcozecchini 0:9fca2b23d0ba 2404 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4) const volatile, B0 b0) {
marcozecchini 0:9fca2b23d0ba 2405 new (this) Event(q, mbed::callback(obj, method), b0);
marcozecchini 0:9fca2b23d0ba 2406 }
marcozecchini 0:9fca2b23d0ba 2407
marcozecchini 0:9fca2b23d0ba 2408 /** Create an event
marcozecchini 0:9fca2b23d0ba 2409 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2410 */
marcozecchini 0:9fca2b23d0ba 2411 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2412 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4), B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2413 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2414 }
marcozecchini 0:9fca2b23d0ba 2415
marcozecchini 0:9fca2b23d0ba 2416 /** Create an event
marcozecchini 0:9fca2b23d0ba 2417 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2418 */
marcozecchini 0:9fca2b23d0ba 2419 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2420 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4) const, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2421 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2422 }
marcozecchini 0:9fca2b23d0ba 2423
marcozecchini 0:9fca2b23d0ba 2424 /** Create an event
marcozecchini 0:9fca2b23d0ba 2425 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2426 */
marcozecchini 0:9fca2b23d0ba 2427 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2428 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4) volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2429 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2430 }
marcozecchini 0:9fca2b23d0ba 2431
marcozecchini 0:9fca2b23d0ba 2432 /** Create an event
marcozecchini 0:9fca2b23d0ba 2433 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2434 */
marcozecchini 0:9fca2b23d0ba 2435 template <typename T, typename R, typename B0, typename B1>
marcozecchini 0:9fca2b23d0ba 2436 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4) const volatile, B0 b0, B1 b1) {
marcozecchini 0:9fca2b23d0ba 2437 new (this) Event(q, mbed::callback(obj, method), b0, b1);
marcozecchini 0:9fca2b23d0ba 2438 }
marcozecchini 0:9fca2b23d0ba 2439
marcozecchini 0:9fca2b23d0ba 2440 /** Create an event
marcozecchini 0:9fca2b23d0ba 2441 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2442 */
marcozecchini 0:9fca2b23d0ba 2443 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2444 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4), B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2445 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2446 }
marcozecchini 0:9fca2b23d0ba 2447
marcozecchini 0:9fca2b23d0ba 2448 /** Create an event
marcozecchini 0:9fca2b23d0ba 2449 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2450 */
marcozecchini 0:9fca2b23d0ba 2451 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2452 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4) const, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2453 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2454 }
marcozecchini 0:9fca2b23d0ba 2455
marcozecchini 0:9fca2b23d0ba 2456 /** Create an event
marcozecchini 0:9fca2b23d0ba 2457 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2458 */
marcozecchini 0:9fca2b23d0ba 2459 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2460 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4) volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2461 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2462 }
marcozecchini 0:9fca2b23d0ba 2463
marcozecchini 0:9fca2b23d0ba 2464 /** Create an event
marcozecchini 0:9fca2b23d0ba 2465 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2466 */
marcozecchini 0:9fca2b23d0ba 2467 template <typename T, typename R, typename B0, typename B1, typename B2>
marcozecchini 0:9fca2b23d0ba 2468 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4) const volatile, B0 b0, B1 b1, B2 b2) {
marcozecchini 0:9fca2b23d0ba 2469 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2);
marcozecchini 0:9fca2b23d0ba 2470 }
marcozecchini 0:9fca2b23d0ba 2471
marcozecchini 0:9fca2b23d0ba 2472 /** Create an event
marcozecchini 0:9fca2b23d0ba 2473 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2474 */
marcozecchini 0:9fca2b23d0ba 2475 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2476 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4), B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2477 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2478 }
marcozecchini 0:9fca2b23d0ba 2479
marcozecchini 0:9fca2b23d0ba 2480 /** Create an event
marcozecchini 0:9fca2b23d0ba 2481 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2482 */
marcozecchini 0:9fca2b23d0ba 2483 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2484 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4) const, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2485 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2486 }
marcozecchini 0:9fca2b23d0ba 2487
marcozecchini 0:9fca2b23d0ba 2488 /** Create an event
marcozecchini 0:9fca2b23d0ba 2489 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2490 */
marcozecchini 0:9fca2b23d0ba 2491 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2492 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4) volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2493 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2494 }
marcozecchini 0:9fca2b23d0ba 2495
marcozecchini 0:9fca2b23d0ba 2496 /** Create an event
marcozecchini 0:9fca2b23d0ba 2497 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2498 */
marcozecchini 0:9fca2b23d0ba 2499 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3>
marcozecchini 0:9fca2b23d0ba 2500 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4) const volatile, B0 b0, B1 b1, B2 b2, B3 b3) {
marcozecchini 0:9fca2b23d0ba 2501 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3);
marcozecchini 0:9fca2b23d0ba 2502 }
marcozecchini 0:9fca2b23d0ba 2503
marcozecchini 0:9fca2b23d0ba 2504 /** Create an event
marcozecchini 0:9fca2b23d0ba 2505 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2506 */
marcozecchini 0:9fca2b23d0ba 2507 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2508 Event(EventQueue *q, T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4), B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2509 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2510 }
marcozecchini 0:9fca2b23d0ba 2511
marcozecchini 0:9fca2b23d0ba 2512 /** Create an event
marcozecchini 0:9fca2b23d0ba 2513 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2514 */
marcozecchini 0:9fca2b23d0ba 2515 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2516 Event(EventQueue *q, const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4) const, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2517 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2518 }
marcozecchini 0:9fca2b23d0ba 2519
marcozecchini 0:9fca2b23d0ba 2520 /** Create an event
marcozecchini 0:9fca2b23d0ba 2521 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2522 */
marcozecchini 0:9fca2b23d0ba 2523 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2524 Event(EventQueue *q, volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4) volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2525 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2526 }
marcozecchini 0:9fca2b23d0ba 2527
marcozecchini 0:9fca2b23d0ba 2528 /** Create an event
marcozecchini 0:9fca2b23d0ba 2529 * @see Event::Event
marcozecchini 0:9fca2b23d0ba 2530 */
marcozecchini 0:9fca2b23d0ba 2531 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4>
marcozecchini 0:9fca2b23d0ba 2532 Event(EventQueue *q, const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4) const volatile, B0 b0, B1 b1, B2 b2, B3 b3, B4 b4) {
marcozecchini 0:9fca2b23d0ba 2533 new (this) Event(q, mbed::callback(obj, method), b0, b1, b2, b3, b4);
marcozecchini 0:9fca2b23d0ba 2534 }
marcozecchini 0:9fca2b23d0ba 2535 };
marcozecchini 0:9fca2b23d0ba 2536
marcozecchini 0:9fca2b23d0ba 2537
marcozecchini 0:9fca2b23d0ba 2538 /** \addtogroup events */
marcozecchini 0:9fca2b23d0ba 2539 /** @{ */
marcozecchini 0:9fca2b23d0ba 2540
marcozecchini 0:9fca2b23d0ba 2541 // Convenience functions declared here to avoid cyclic
marcozecchini 0:9fca2b23d0ba 2542 // dependency between Event and EventQueue
marcozecchini 0:9fca2b23d0ba 2543 template <typename R>
marcozecchini 0:9fca2b23d0ba 2544 Event<void()> EventQueue::event(R (*func)()) {
marcozecchini 0:9fca2b23d0ba 2545 return Event<void()>(this, func);
marcozecchini 0:9fca2b23d0ba 2546 }
marcozecchini 0:9fca2b23d0ba 2547
marcozecchini 0:9fca2b23d0ba 2548 template <typename T, typename R>
marcozecchini 0:9fca2b23d0ba 2549 Event<void()> EventQueue::event(T *obj, R (T::*method)()) {
marcozecchini 0:9fca2b23d0ba 2550 return Event<void()>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2551 }
marcozecchini 0:9fca2b23d0ba 2552
marcozecchini 0:9fca2b23d0ba 2553 template <typename T, typename R>
marcozecchini 0:9fca2b23d0ba 2554 Event<void()> EventQueue::event(const T *obj, R (T::*method)() const) {
marcozecchini 0:9fca2b23d0ba 2555 return Event<void()>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2556 }
marcozecchini 0:9fca2b23d0ba 2557
marcozecchini 0:9fca2b23d0ba 2558 template <typename T, typename R>
marcozecchini 0:9fca2b23d0ba 2559 Event<void()> EventQueue::event(volatile T *obj, R (T::*method)() volatile) {
marcozecchini 0:9fca2b23d0ba 2560 return Event<void()>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2561 }
marcozecchini 0:9fca2b23d0ba 2562
marcozecchini 0:9fca2b23d0ba 2563 template <typename T, typename R>
marcozecchini 0:9fca2b23d0ba 2564 Event<void()> EventQueue::event(const volatile T *obj, R (T::*method)() const volatile) {
marcozecchini 0:9fca2b23d0ba 2565 return Event<void()>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2566 }
marcozecchini 0:9fca2b23d0ba 2567
marcozecchini 0:9fca2b23d0ba 2568 template <typename R>
marcozecchini 0:9fca2b23d0ba 2569 Event<void()> EventQueue::event(mbed::Callback<R()> cb) {
marcozecchini 0:9fca2b23d0ba 2570 return Event<void()>(this, cb);
marcozecchini 0:9fca2b23d0ba 2571 }
marcozecchini 0:9fca2b23d0ba 2572
marcozecchini 0:9fca2b23d0ba 2573 template <typename R, typename B0, typename C0>
marcozecchini 0:9fca2b23d0ba 2574 Event<void()> EventQueue::event(R (*func)(B0), C0 c0) {
marcozecchini 0:9fca2b23d0ba 2575 return Event<void()>(this, func, c0);
marcozecchini 0:9fca2b23d0ba 2576 }
marcozecchini 0:9fca2b23d0ba 2577
marcozecchini 0:9fca2b23d0ba 2578 template <typename T, typename R, typename B0, typename C0>
marcozecchini 0:9fca2b23d0ba 2579 Event<void()> EventQueue::event(T *obj, R (T::*method)(B0), C0 c0) {
marcozecchini 0:9fca2b23d0ba 2580 return Event<void()>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2581 }
marcozecchini 0:9fca2b23d0ba 2582
marcozecchini 0:9fca2b23d0ba 2583 template <typename T, typename R, typename B0, typename C0>
marcozecchini 0:9fca2b23d0ba 2584 Event<void()> EventQueue::event(const T *obj, R (T::*method)(B0) const, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2585 return Event<void()>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2586 }
marcozecchini 0:9fca2b23d0ba 2587
marcozecchini 0:9fca2b23d0ba 2588 template <typename T, typename R, typename B0, typename C0>
marcozecchini 0:9fca2b23d0ba 2589 Event<void()> EventQueue::event(volatile T *obj, R (T::*method)(B0) volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2590 return Event<void()>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2591 }
marcozecchini 0:9fca2b23d0ba 2592
marcozecchini 0:9fca2b23d0ba 2593 template <typename T, typename R, typename B0, typename C0>
marcozecchini 0:9fca2b23d0ba 2594 Event<void()> EventQueue::event(const volatile T *obj, R (T::*method)(B0) const volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2595 return Event<void()>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2596 }
marcozecchini 0:9fca2b23d0ba 2597
marcozecchini 0:9fca2b23d0ba 2598 template <typename R, typename B0, typename C0>
marcozecchini 0:9fca2b23d0ba 2599 Event<void()> EventQueue::event(mbed::Callback<R(B0)> cb, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2600 return Event<void()>(this, cb, c0);
marcozecchini 0:9fca2b23d0ba 2601 }
marcozecchini 0:9fca2b23d0ba 2602
marcozecchini 0:9fca2b23d0ba 2603 template <typename R, typename B0, typename B1, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2604 Event<void()> EventQueue::event(R (*func)(B0, B1), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2605 return Event<void()>(this, func, c0, c1);
marcozecchini 0:9fca2b23d0ba 2606 }
marcozecchini 0:9fca2b23d0ba 2607
marcozecchini 0:9fca2b23d0ba 2608 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2609 Event<void()> EventQueue::event(T *obj, R (T::*method)(B0, B1), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2610 return Event<void()>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2611 }
marcozecchini 0:9fca2b23d0ba 2612
marcozecchini 0:9fca2b23d0ba 2613 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2614 Event<void()> EventQueue::event(const T *obj, R (T::*method)(B0, B1) const, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2615 return Event<void()>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2616 }
marcozecchini 0:9fca2b23d0ba 2617
marcozecchini 0:9fca2b23d0ba 2618 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2619 Event<void()> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1) volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2620 return Event<void()>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2621 }
marcozecchini 0:9fca2b23d0ba 2622
marcozecchini 0:9fca2b23d0ba 2623 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2624 Event<void()> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1) const volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2625 return Event<void()>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2626 }
marcozecchini 0:9fca2b23d0ba 2627
marcozecchini 0:9fca2b23d0ba 2628 template <typename R, typename B0, typename B1, typename C0, typename C1>
marcozecchini 0:9fca2b23d0ba 2629 Event<void()> EventQueue::event(mbed::Callback<R(B0, B1)> cb, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2630 return Event<void()>(this, cb, c0, c1);
marcozecchini 0:9fca2b23d0ba 2631 }
marcozecchini 0:9fca2b23d0ba 2632
marcozecchini 0:9fca2b23d0ba 2633 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2634 Event<void()> EventQueue::event(R (*func)(B0, B1, B2), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2635 return Event<void()>(this, func, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2636 }
marcozecchini 0:9fca2b23d0ba 2637
marcozecchini 0:9fca2b23d0ba 2638 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2639 Event<void()> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2640 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2641 }
marcozecchini 0:9fca2b23d0ba 2642
marcozecchini 0:9fca2b23d0ba 2643 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2644 Event<void()> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2) const, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2645 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2646 }
marcozecchini 0:9fca2b23d0ba 2647
marcozecchini 0:9fca2b23d0ba 2648 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2649 Event<void()> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2) volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2650 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2651 }
marcozecchini 0:9fca2b23d0ba 2652
marcozecchini 0:9fca2b23d0ba 2653 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2654 Event<void()> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2) const volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2655 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2656 }
marcozecchini 0:9fca2b23d0ba 2657
marcozecchini 0:9fca2b23d0ba 2658 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2>
marcozecchini 0:9fca2b23d0ba 2659 Event<void()> EventQueue::event(mbed::Callback<R(B0, B1, B2)> cb, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2660 return Event<void()>(this, cb, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2661 }
marcozecchini 0:9fca2b23d0ba 2662
marcozecchini 0:9fca2b23d0ba 2663 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2664 Event<void()> EventQueue::event(R (*func)(B0, B1, B2, B3), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2665 return Event<void()>(this, func, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2666 }
marcozecchini 0:9fca2b23d0ba 2667
marcozecchini 0:9fca2b23d0ba 2668 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2669 Event<void()> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2670 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2671 }
marcozecchini 0:9fca2b23d0ba 2672
marcozecchini 0:9fca2b23d0ba 2673 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2674 Event<void()> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3) const, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2675 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2676 }
marcozecchini 0:9fca2b23d0ba 2677
marcozecchini 0:9fca2b23d0ba 2678 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2679 Event<void()> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3) volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2680 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2681 }
marcozecchini 0:9fca2b23d0ba 2682
marcozecchini 0:9fca2b23d0ba 2683 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2684 Event<void()> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3) const volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2685 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2686 }
marcozecchini 0:9fca2b23d0ba 2687
marcozecchini 0:9fca2b23d0ba 2688 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3>
marcozecchini 0:9fca2b23d0ba 2689 Event<void()> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3)> cb, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2690 return Event<void()>(this, cb, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2691 }
marcozecchini 0:9fca2b23d0ba 2692
marcozecchini 0:9fca2b23d0ba 2693 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2694 Event<void()> EventQueue::event(R (*func)(B0, B1, B2, B3, B4), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2695 return Event<void()>(this, func, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2696 }
marcozecchini 0:9fca2b23d0ba 2697
marcozecchini 0:9fca2b23d0ba 2698 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2699 Event<void()> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, B4), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2700 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2701 }
marcozecchini 0:9fca2b23d0ba 2702
marcozecchini 0:9fca2b23d0ba 2703 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2704 Event<void()> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, B4) const, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2705 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2706 }
marcozecchini 0:9fca2b23d0ba 2707
marcozecchini 0:9fca2b23d0ba 2708 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2709 Event<void()> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4) volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2710 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2711 }
marcozecchini 0:9fca2b23d0ba 2712
marcozecchini 0:9fca2b23d0ba 2713 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2714 Event<void()> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4) const volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2715 return Event<void()>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2716 }
marcozecchini 0:9fca2b23d0ba 2717
marcozecchini 0:9fca2b23d0ba 2718 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4>
marcozecchini 0:9fca2b23d0ba 2719 Event<void()> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, B4)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2720 return Event<void()>(this, cb, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2721 }
marcozecchini 0:9fca2b23d0ba 2722
marcozecchini 0:9fca2b23d0ba 2723 template <typename R, typename A0>
marcozecchini 0:9fca2b23d0ba 2724 Event<void(A0)> EventQueue::event(R (*func)(A0)) {
marcozecchini 0:9fca2b23d0ba 2725 return Event<void(A0)>(this, func);
marcozecchini 0:9fca2b23d0ba 2726 }
marcozecchini 0:9fca2b23d0ba 2727
marcozecchini 0:9fca2b23d0ba 2728 template <typename T, typename R, typename A0>
marcozecchini 0:9fca2b23d0ba 2729 Event<void(A0)> EventQueue::event(T *obj, R (T::*method)(A0)) {
marcozecchini 0:9fca2b23d0ba 2730 return Event<void(A0)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2731 }
marcozecchini 0:9fca2b23d0ba 2732
marcozecchini 0:9fca2b23d0ba 2733 template <typename T, typename R, typename A0>
marcozecchini 0:9fca2b23d0ba 2734 Event<void(A0)> EventQueue::event(const T *obj, R (T::*method)(A0) const) {
marcozecchini 0:9fca2b23d0ba 2735 return Event<void(A0)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2736 }
marcozecchini 0:9fca2b23d0ba 2737
marcozecchini 0:9fca2b23d0ba 2738 template <typename T, typename R, typename A0>
marcozecchini 0:9fca2b23d0ba 2739 Event<void(A0)> EventQueue::event(volatile T *obj, R (T::*method)(A0) volatile) {
marcozecchini 0:9fca2b23d0ba 2740 return Event<void(A0)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2741 }
marcozecchini 0:9fca2b23d0ba 2742
marcozecchini 0:9fca2b23d0ba 2743 template <typename T, typename R, typename A0>
marcozecchini 0:9fca2b23d0ba 2744 Event<void(A0)> EventQueue::event(const volatile T *obj, R (T::*method)(A0) const volatile) {
marcozecchini 0:9fca2b23d0ba 2745 return Event<void(A0)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2746 }
marcozecchini 0:9fca2b23d0ba 2747
marcozecchini 0:9fca2b23d0ba 2748 template <typename R, typename A0>
marcozecchini 0:9fca2b23d0ba 2749 Event<void(A0)> EventQueue::event(mbed::Callback<R(A0)> cb) {
marcozecchini 0:9fca2b23d0ba 2750 return Event<void(A0)>(this, cb);
marcozecchini 0:9fca2b23d0ba 2751 }
marcozecchini 0:9fca2b23d0ba 2752
marcozecchini 0:9fca2b23d0ba 2753 template <typename R, typename B0, typename C0, typename A0>
marcozecchini 0:9fca2b23d0ba 2754 Event<void(A0)> EventQueue::event(R (*func)(B0, A0), C0 c0) {
marcozecchini 0:9fca2b23d0ba 2755 return Event<void(A0)>(this, func, c0);
marcozecchini 0:9fca2b23d0ba 2756 }
marcozecchini 0:9fca2b23d0ba 2757
marcozecchini 0:9fca2b23d0ba 2758 template <typename T, typename R, typename B0, typename C0, typename A0>
marcozecchini 0:9fca2b23d0ba 2759 Event<void(A0)> EventQueue::event(T *obj, R (T::*method)(B0, A0), C0 c0) {
marcozecchini 0:9fca2b23d0ba 2760 return Event<void(A0)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2761 }
marcozecchini 0:9fca2b23d0ba 2762
marcozecchini 0:9fca2b23d0ba 2763 template <typename T, typename R, typename B0, typename C0, typename A0>
marcozecchini 0:9fca2b23d0ba 2764 Event<void(A0)> EventQueue::event(const T *obj, R (T::*method)(B0, A0) const, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2765 return Event<void(A0)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2766 }
marcozecchini 0:9fca2b23d0ba 2767
marcozecchini 0:9fca2b23d0ba 2768 template <typename T, typename R, typename B0, typename C0, typename A0>
marcozecchini 0:9fca2b23d0ba 2769 Event<void(A0)> EventQueue::event(volatile T *obj, R (T::*method)(B0, A0) volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2770 return Event<void(A0)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2771 }
marcozecchini 0:9fca2b23d0ba 2772
marcozecchini 0:9fca2b23d0ba 2773 template <typename T, typename R, typename B0, typename C0, typename A0>
marcozecchini 0:9fca2b23d0ba 2774 Event<void(A0)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, A0) const volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2775 return Event<void(A0)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2776 }
marcozecchini 0:9fca2b23d0ba 2777
marcozecchini 0:9fca2b23d0ba 2778 template <typename R, typename B0, typename C0, typename A0>
marcozecchini 0:9fca2b23d0ba 2779 Event<void(A0)> EventQueue::event(mbed::Callback<R(B0, A0)> cb, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2780 return Event<void(A0)>(this, cb, c0);
marcozecchini 0:9fca2b23d0ba 2781 }
marcozecchini 0:9fca2b23d0ba 2782
marcozecchini 0:9fca2b23d0ba 2783 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0>
marcozecchini 0:9fca2b23d0ba 2784 Event<void(A0)> EventQueue::event(R (*func)(B0, B1, A0), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2785 return Event<void(A0)>(this, func, c0, c1);
marcozecchini 0:9fca2b23d0ba 2786 }
marcozecchini 0:9fca2b23d0ba 2787
marcozecchini 0:9fca2b23d0ba 2788 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0>
marcozecchini 0:9fca2b23d0ba 2789 Event<void(A0)> EventQueue::event(T *obj, R (T::*method)(B0, B1, A0), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2790 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2791 }
marcozecchini 0:9fca2b23d0ba 2792
marcozecchini 0:9fca2b23d0ba 2793 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0>
marcozecchini 0:9fca2b23d0ba 2794 Event<void(A0)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, A0) const, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2795 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2796 }
marcozecchini 0:9fca2b23d0ba 2797
marcozecchini 0:9fca2b23d0ba 2798 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0>
marcozecchini 0:9fca2b23d0ba 2799 Event<void(A0)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, A0) volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2800 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2801 }
marcozecchini 0:9fca2b23d0ba 2802
marcozecchini 0:9fca2b23d0ba 2803 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0>
marcozecchini 0:9fca2b23d0ba 2804 Event<void(A0)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, A0) const volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2805 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2806 }
marcozecchini 0:9fca2b23d0ba 2807
marcozecchini 0:9fca2b23d0ba 2808 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0>
marcozecchini 0:9fca2b23d0ba 2809 Event<void(A0)> EventQueue::event(mbed::Callback<R(B0, B1, A0)> cb, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2810 return Event<void(A0)>(this, cb, c0, c1);
marcozecchini 0:9fca2b23d0ba 2811 }
marcozecchini 0:9fca2b23d0ba 2812
marcozecchini 0:9fca2b23d0ba 2813 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0>
marcozecchini 0:9fca2b23d0ba 2814 Event<void(A0)> EventQueue::event(R (*func)(B0, B1, B2, A0), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2815 return Event<void(A0)>(this, func, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2816 }
marcozecchini 0:9fca2b23d0ba 2817
marcozecchini 0:9fca2b23d0ba 2818 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0>
marcozecchini 0:9fca2b23d0ba 2819 Event<void(A0)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, A0), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2820 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2821 }
marcozecchini 0:9fca2b23d0ba 2822
marcozecchini 0:9fca2b23d0ba 2823 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0>
marcozecchini 0:9fca2b23d0ba 2824 Event<void(A0)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, A0) const, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2825 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2826 }
marcozecchini 0:9fca2b23d0ba 2827
marcozecchini 0:9fca2b23d0ba 2828 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0>
marcozecchini 0:9fca2b23d0ba 2829 Event<void(A0)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, A0) volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2830 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2831 }
marcozecchini 0:9fca2b23d0ba 2832
marcozecchini 0:9fca2b23d0ba 2833 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0>
marcozecchini 0:9fca2b23d0ba 2834 Event<void(A0)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, A0) const volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2835 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2836 }
marcozecchini 0:9fca2b23d0ba 2837
marcozecchini 0:9fca2b23d0ba 2838 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0>
marcozecchini 0:9fca2b23d0ba 2839 Event<void(A0)> EventQueue::event(mbed::Callback<R(B0, B1, B2, A0)> cb, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2840 return Event<void(A0)>(this, cb, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2841 }
marcozecchini 0:9fca2b23d0ba 2842
marcozecchini 0:9fca2b23d0ba 2843 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0>
marcozecchini 0:9fca2b23d0ba 2844 Event<void(A0)> EventQueue::event(R (*func)(B0, B1, B2, B3, A0), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2845 return Event<void(A0)>(this, func, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2846 }
marcozecchini 0:9fca2b23d0ba 2847
marcozecchini 0:9fca2b23d0ba 2848 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0>
marcozecchini 0:9fca2b23d0ba 2849 Event<void(A0)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, A0), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2850 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2851 }
marcozecchini 0:9fca2b23d0ba 2852
marcozecchini 0:9fca2b23d0ba 2853 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0>
marcozecchini 0:9fca2b23d0ba 2854 Event<void(A0)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, A0) const, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2855 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2856 }
marcozecchini 0:9fca2b23d0ba 2857
marcozecchini 0:9fca2b23d0ba 2858 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0>
marcozecchini 0:9fca2b23d0ba 2859 Event<void(A0)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0) volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2860 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2861 }
marcozecchini 0:9fca2b23d0ba 2862
marcozecchini 0:9fca2b23d0ba 2863 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0>
marcozecchini 0:9fca2b23d0ba 2864 Event<void(A0)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0) const volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2865 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2866 }
marcozecchini 0:9fca2b23d0ba 2867
marcozecchini 0:9fca2b23d0ba 2868 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0>
marcozecchini 0:9fca2b23d0ba 2869 Event<void(A0)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, A0)> cb, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 2870 return Event<void(A0)>(this, cb, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 2871 }
marcozecchini 0:9fca2b23d0ba 2872
marcozecchini 0:9fca2b23d0ba 2873 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0>
marcozecchini 0:9fca2b23d0ba 2874 Event<void(A0)> EventQueue::event(R (*func)(B0, B1, B2, B3, B4, A0), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2875 return Event<void(A0)>(this, func, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2876 }
marcozecchini 0:9fca2b23d0ba 2877
marcozecchini 0:9fca2b23d0ba 2878 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0>
marcozecchini 0:9fca2b23d0ba 2879 Event<void(A0)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2880 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2881 }
marcozecchini 0:9fca2b23d0ba 2882
marcozecchini 0:9fca2b23d0ba 2883 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0>
marcozecchini 0:9fca2b23d0ba 2884 Event<void(A0)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0) const, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2885 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2886 }
marcozecchini 0:9fca2b23d0ba 2887
marcozecchini 0:9fca2b23d0ba 2888 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0>
marcozecchini 0:9fca2b23d0ba 2889 Event<void(A0)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0) volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2890 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2891 }
marcozecchini 0:9fca2b23d0ba 2892
marcozecchini 0:9fca2b23d0ba 2893 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0>
marcozecchini 0:9fca2b23d0ba 2894 Event<void(A0)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0) const volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2895 return Event<void(A0)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2896 }
marcozecchini 0:9fca2b23d0ba 2897
marcozecchini 0:9fca2b23d0ba 2898 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0>
marcozecchini 0:9fca2b23d0ba 2899 Event<void(A0)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, B4, A0)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 2900 return Event<void(A0)>(this, cb, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 2901 }
marcozecchini 0:9fca2b23d0ba 2902
marcozecchini 0:9fca2b23d0ba 2903 template <typename R, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2904 Event<void(A0, A1)> EventQueue::event(R (*func)(A0, A1)) {
marcozecchini 0:9fca2b23d0ba 2905 return Event<void(A0, A1)>(this, func);
marcozecchini 0:9fca2b23d0ba 2906 }
marcozecchini 0:9fca2b23d0ba 2907
marcozecchini 0:9fca2b23d0ba 2908 template <typename T, typename R, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2909 Event<void(A0, A1)> EventQueue::event(T *obj, R (T::*method)(A0, A1)) {
marcozecchini 0:9fca2b23d0ba 2910 return Event<void(A0, A1)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2911 }
marcozecchini 0:9fca2b23d0ba 2912
marcozecchini 0:9fca2b23d0ba 2913 template <typename T, typename R, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2914 Event<void(A0, A1)> EventQueue::event(const T *obj, R (T::*method)(A0, A1) const) {
marcozecchini 0:9fca2b23d0ba 2915 return Event<void(A0, A1)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2916 }
marcozecchini 0:9fca2b23d0ba 2917
marcozecchini 0:9fca2b23d0ba 2918 template <typename T, typename R, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2919 Event<void(A0, A1)> EventQueue::event(volatile T *obj, R (T::*method)(A0, A1) volatile) {
marcozecchini 0:9fca2b23d0ba 2920 return Event<void(A0, A1)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2921 }
marcozecchini 0:9fca2b23d0ba 2922
marcozecchini 0:9fca2b23d0ba 2923 template <typename T, typename R, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2924 Event<void(A0, A1)> EventQueue::event(const volatile T *obj, R (T::*method)(A0, A1) const volatile) {
marcozecchini 0:9fca2b23d0ba 2925 return Event<void(A0, A1)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 2926 }
marcozecchini 0:9fca2b23d0ba 2927
marcozecchini 0:9fca2b23d0ba 2928 template <typename R, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2929 Event<void(A0, A1)> EventQueue::event(mbed::Callback<R(A0, A1)> cb) {
marcozecchini 0:9fca2b23d0ba 2930 return Event<void(A0, A1)>(this, cb);
marcozecchini 0:9fca2b23d0ba 2931 }
marcozecchini 0:9fca2b23d0ba 2932
marcozecchini 0:9fca2b23d0ba 2933 template <typename R, typename B0, typename C0, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2934 Event<void(A0, A1)> EventQueue::event(R (*func)(B0, A0, A1), C0 c0) {
marcozecchini 0:9fca2b23d0ba 2935 return Event<void(A0, A1)>(this, func, c0);
marcozecchini 0:9fca2b23d0ba 2936 }
marcozecchini 0:9fca2b23d0ba 2937
marcozecchini 0:9fca2b23d0ba 2938 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2939 Event<void(A0, A1)> EventQueue::event(T *obj, R (T::*method)(B0, A0, A1), C0 c0) {
marcozecchini 0:9fca2b23d0ba 2940 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2941 }
marcozecchini 0:9fca2b23d0ba 2942
marcozecchini 0:9fca2b23d0ba 2943 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2944 Event<void(A0, A1)> EventQueue::event(const T *obj, R (T::*method)(B0, A0, A1) const, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2945 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2946 }
marcozecchini 0:9fca2b23d0ba 2947
marcozecchini 0:9fca2b23d0ba 2948 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2949 Event<void(A0, A1)> EventQueue::event(volatile T *obj, R (T::*method)(B0, A0, A1) volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2950 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2951 }
marcozecchini 0:9fca2b23d0ba 2952
marcozecchini 0:9fca2b23d0ba 2953 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2954 Event<void(A0, A1)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, A0, A1) const volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2955 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 2956 }
marcozecchini 0:9fca2b23d0ba 2957
marcozecchini 0:9fca2b23d0ba 2958 template <typename R, typename B0, typename C0, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2959 Event<void(A0, A1)> EventQueue::event(mbed::Callback<R(B0, A0, A1)> cb, C0 c0) {
marcozecchini 0:9fca2b23d0ba 2960 return Event<void(A0, A1)>(this, cb, c0);
marcozecchini 0:9fca2b23d0ba 2961 }
marcozecchini 0:9fca2b23d0ba 2962
marcozecchini 0:9fca2b23d0ba 2963 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2964 Event<void(A0, A1)> EventQueue::event(R (*func)(B0, B1, A0, A1), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2965 return Event<void(A0, A1)>(this, func, c0, c1);
marcozecchini 0:9fca2b23d0ba 2966 }
marcozecchini 0:9fca2b23d0ba 2967
marcozecchini 0:9fca2b23d0ba 2968 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2969 Event<void(A0, A1)> EventQueue::event(T *obj, R (T::*method)(B0, B1, A0, A1), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2970 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2971 }
marcozecchini 0:9fca2b23d0ba 2972
marcozecchini 0:9fca2b23d0ba 2973 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2974 Event<void(A0, A1)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, A0, A1) const, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2975 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2976 }
marcozecchini 0:9fca2b23d0ba 2977
marcozecchini 0:9fca2b23d0ba 2978 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2979 Event<void(A0, A1)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, A0, A1) volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2980 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2981 }
marcozecchini 0:9fca2b23d0ba 2982
marcozecchini 0:9fca2b23d0ba 2983 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2984 Event<void(A0, A1)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, A0, A1) const volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2985 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 2986 }
marcozecchini 0:9fca2b23d0ba 2987
marcozecchini 0:9fca2b23d0ba 2988 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2989 Event<void(A0, A1)> EventQueue::event(mbed::Callback<R(B0, B1, A0, A1)> cb, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 2990 return Event<void(A0, A1)>(this, cb, c0, c1);
marcozecchini 0:9fca2b23d0ba 2991 }
marcozecchini 0:9fca2b23d0ba 2992
marcozecchini 0:9fca2b23d0ba 2993 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2994 Event<void(A0, A1)> EventQueue::event(R (*func)(B0, B1, B2, A0, A1), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 2995 return Event<void(A0, A1)>(this, func, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 2996 }
marcozecchini 0:9fca2b23d0ba 2997
marcozecchini 0:9fca2b23d0ba 2998 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 2999 Event<void(A0, A1)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, A0, A1), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3000 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3001 }
marcozecchini 0:9fca2b23d0ba 3002
marcozecchini 0:9fca2b23d0ba 3003 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3004 Event<void(A0, A1)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, A0, A1) const, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3005 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3006 }
marcozecchini 0:9fca2b23d0ba 3007
marcozecchini 0:9fca2b23d0ba 3008 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3009 Event<void(A0, A1)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1) volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3010 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3011 }
marcozecchini 0:9fca2b23d0ba 3012
marcozecchini 0:9fca2b23d0ba 3013 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3014 Event<void(A0, A1)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1) const volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3015 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3016 }
marcozecchini 0:9fca2b23d0ba 3017
marcozecchini 0:9fca2b23d0ba 3018 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3019 Event<void(A0, A1)> EventQueue::event(mbed::Callback<R(B0, B1, B2, A0, A1)> cb, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3020 return Event<void(A0, A1)>(this, cb, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3021 }
marcozecchini 0:9fca2b23d0ba 3022
marcozecchini 0:9fca2b23d0ba 3023 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3024 Event<void(A0, A1)> EventQueue::event(R (*func)(B0, B1, B2, B3, A0, A1), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3025 return Event<void(A0, A1)>(this, func, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3026 }
marcozecchini 0:9fca2b23d0ba 3027
marcozecchini 0:9fca2b23d0ba 3028 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3029 Event<void(A0, A1)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3030 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3031 }
marcozecchini 0:9fca2b23d0ba 3032
marcozecchini 0:9fca2b23d0ba 3033 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3034 Event<void(A0, A1)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1) const, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3035 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3036 }
marcozecchini 0:9fca2b23d0ba 3037
marcozecchini 0:9fca2b23d0ba 3038 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3039 Event<void(A0, A1)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1) volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3040 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3041 }
marcozecchini 0:9fca2b23d0ba 3042
marcozecchini 0:9fca2b23d0ba 3043 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3044 Event<void(A0, A1)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1) const volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3045 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3046 }
marcozecchini 0:9fca2b23d0ba 3047
marcozecchini 0:9fca2b23d0ba 3048 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3049 Event<void(A0, A1)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, A0, A1)> cb, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3050 return Event<void(A0, A1)>(this, cb, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3051 }
marcozecchini 0:9fca2b23d0ba 3052
marcozecchini 0:9fca2b23d0ba 3053 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3054 Event<void(A0, A1)> EventQueue::event(R (*func)(B0, B1, B2, B3, B4, A0, A1), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3055 return Event<void(A0, A1)>(this, func, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3056 }
marcozecchini 0:9fca2b23d0ba 3057
marcozecchini 0:9fca2b23d0ba 3058 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3059 Event<void(A0, A1)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3060 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3061 }
marcozecchini 0:9fca2b23d0ba 3062
marcozecchini 0:9fca2b23d0ba 3063 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3064 Event<void(A0, A1)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1) const, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3065 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3066 }
marcozecchini 0:9fca2b23d0ba 3067
marcozecchini 0:9fca2b23d0ba 3068 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3069 Event<void(A0, A1)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1) volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3070 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3071 }
marcozecchini 0:9fca2b23d0ba 3072
marcozecchini 0:9fca2b23d0ba 3073 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3074 Event<void(A0, A1)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1) const volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3075 return Event<void(A0, A1)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3076 }
marcozecchini 0:9fca2b23d0ba 3077
marcozecchini 0:9fca2b23d0ba 3078 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1>
marcozecchini 0:9fca2b23d0ba 3079 Event<void(A0, A1)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, B4, A0, A1)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3080 return Event<void(A0, A1)>(this, cb, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3081 }
marcozecchini 0:9fca2b23d0ba 3082
marcozecchini 0:9fca2b23d0ba 3083 template <typename R, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3084 Event<void(A0, A1, A2)> EventQueue::event(R (*func)(A0, A1, A2)) {
marcozecchini 0:9fca2b23d0ba 3085 return Event<void(A0, A1, A2)>(this, func);
marcozecchini 0:9fca2b23d0ba 3086 }
marcozecchini 0:9fca2b23d0ba 3087
marcozecchini 0:9fca2b23d0ba 3088 template <typename T, typename R, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3089 Event<void(A0, A1, A2)> EventQueue::event(T *obj, R (T::*method)(A0, A1, A2)) {
marcozecchini 0:9fca2b23d0ba 3090 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3091 }
marcozecchini 0:9fca2b23d0ba 3092
marcozecchini 0:9fca2b23d0ba 3093 template <typename T, typename R, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3094 Event<void(A0, A1, A2)> EventQueue::event(const T *obj, R (T::*method)(A0, A1, A2) const) {
marcozecchini 0:9fca2b23d0ba 3095 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3096 }
marcozecchini 0:9fca2b23d0ba 3097
marcozecchini 0:9fca2b23d0ba 3098 template <typename T, typename R, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3099 Event<void(A0, A1, A2)> EventQueue::event(volatile T *obj, R (T::*method)(A0, A1, A2) volatile) {
marcozecchini 0:9fca2b23d0ba 3100 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3101 }
marcozecchini 0:9fca2b23d0ba 3102
marcozecchini 0:9fca2b23d0ba 3103 template <typename T, typename R, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3104 Event<void(A0, A1, A2)> EventQueue::event(const volatile T *obj, R (T::*method)(A0, A1, A2) const volatile) {
marcozecchini 0:9fca2b23d0ba 3105 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3106 }
marcozecchini 0:9fca2b23d0ba 3107
marcozecchini 0:9fca2b23d0ba 3108 template <typename R, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3109 Event<void(A0, A1, A2)> EventQueue::event(mbed::Callback<R(A0, A1, A2)> cb) {
marcozecchini 0:9fca2b23d0ba 3110 return Event<void(A0, A1, A2)>(this, cb);
marcozecchini 0:9fca2b23d0ba 3111 }
marcozecchini 0:9fca2b23d0ba 3112
marcozecchini 0:9fca2b23d0ba 3113 template <typename R, typename B0, typename C0, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3114 Event<void(A0, A1, A2)> EventQueue::event(R (*func)(B0, A0, A1, A2), C0 c0) {
marcozecchini 0:9fca2b23d0ba 3115 return Event<void(A0, A1, A2)>(this, func, c0);
marcozecchini 0:9fca2b23d0ba 3116 }
marcozecchini 0:9fca2b23d0ba 3117
marcozecchini 0:9fca2b23d0ba 3118 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3119 Event<void(A0, A1, A2)> EventQueue::event(T *obj, R (T::*method)(B0, A0, A1, A2), C0 c0) {
marcozecchini 0:9fca2b23d0ba 3120 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3121 }
marcozecchini 0:9fca2b23d0ba 3122
marcozecchini 0:9fca2b23d0ba 3123 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3124 Event<void(A0, A1, A2)> EventQueue::event(const T *obj, R (T::*method)(B0, A0, A1, A2) const, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3125 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3126 }
marcozecchini 0:9fca2b23d0ba 3127
marcozecchini 0:9fca2b23d0ba 3128 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3129 Event<void(A0, A1, A2)> EventQueue::event(volatile T *obj, R (T::*method)(B0, A0, A1, A2) volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3130 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3131 }
marcozecchini 0:9fca2b23d0ba 3132
marcozecchini 0:9fca2b23d0ba 3133 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3134 Event<void(A0, A1, A2)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, A0, A1, A2) const volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3135 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3136 }
marcozecchini 0:9fca2b23d0ba 3137
marcozecchini 0:9fca2b23d0ba 3138 template <typename R, typename B0, typename C0, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3139 Event<void(A0, A1, A2)> EventQueue::event(mbed::Callback<R(B0, A0, A1, A2)> cb, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3140 return Event<void(A0, A1, A2)>(this, cb, c0);
marcozecchini 0:9fca2b23d0ba 3141 }
marcozecchini 0:9fca2b23d0ba 3142
marcozecchini 0:9fca2b23d0ba 3143 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3144 Event<void(A0, A1, A2)> EventQueue::event(R (*func)(B0, B1, A0, A1, A2), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3145 return Event<void(A0, A1, A2)>(this, func, c0, c1);
marcozecchini 0:9fca2b23d0ba 3146 }
marcozecchini 0:9fca2b23d0ba 3147
marcozecchini 0:9fca2b23d0ba 3148 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3149 Event<void(A0, A1, A2)> EventQueue::event(T *obj, R (T::*method)(B0, B1, A0, A1, A2), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3150 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3151 }
marcozecchini 0:9fca2b23d0ba 3152
marcozecchini 0:9fca2b23d0ba 3153 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3154 Event<void(A0, A1, A2)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, A0, A1, A2) const, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3155 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3156 }
marcozecchini 0:9fca2b23d0ba 3157
marcozecchini 0:9fca2b23d0ba 3158 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3159 Event<void(A0, A1, A2)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2) volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3160 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3161 }
marcozecchini 0:9fca2b23d0ba 3162
marcozecchini 0:9fca2b23d0ba 3163 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3164 Event<void(A0, A1, A2)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2) const volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3165 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3166 }
marcozecchini 0:9fca2b23d0ba 3167
marcozecchini 0:9fca2b23d0ba 3168 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3169 Event<void(A0, A1, A2)> EventQueue::event(mbed::Callback<R(B0, B1, A0, A1, A2)> cb, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3170 return Event<void(A0, A1, A2)>(this, cb, c0, c1);
marcozecchini 0:9fca2b23d0ba 3171 }
marcozecchini 0:9fca2b23d0ba 3172
marcozecchini 0:9fca2b23d0ba 3173 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3174 Event<void(A0, A1, A2)> EventQueue::event(R (*func)(B0, B1, B2, A0, A1, A2), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3175 return Event<void(A0, A1, A2)>(this, func, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3176 }
marcozecchini 0:9fca2b23d0ba 3177
marcozecchini 0:9fca2b23d0ba 3178 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3179 Event<void(A0, A1, A2)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3180 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3181 }
marcozecchini 0:9fca2b23d0ba 3182
marcozecchini 0:9fca2b23d0ba 3183 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3184 Event<void(A0, A1, A2)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2) const, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3185 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3186 }
marcozecchini 0:9fca2b23d0ba 3187
marcozecchini 0:9fca2b23d0ba 3188 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3189 Event<void(A0, A1, A2)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2) volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3190 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3191 }
marcozecchini 0:9fca2b23d0ba 3192
marcozecchini 0:9fca2b23d0ba 3193 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3194 Event<void(A0, A1, A2)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2) const volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3195 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3196 }
marcozecchini 0:9fca2b23d0ba 3197
marcozecchini 0:9fca2b23d0ba 3198 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3199 Event<void(A0, A1, A2)> EventQueue::event(mbed::Callback<R(B0, B1, B2, A0, A1, A2)> cb, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3200 return Event<void(A0, A1, A2)>(this, cb, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3201 }
marcozecchini 0:9fca2b23d0ba 3202
marcozecchini 0:9fca2b23d0ba 3203 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3204 Event<void(A0, A1, A2)> EventQueue::event(R (*func)(B0, B1, B2, B3, A0, A1, A2), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3205 return Event<void(A0, A1, A2)>(this, func, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3206 }
marcozecchini 0:9fca2b23d0ba 3207
marcozecchini 0:9fca2b23d0ba 3208 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3209 Event<void(A0, A1, A2)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3210 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3211 }
marcozecchini 0:9fca2b23d0ba 3212
marcozecchini 0:9fca2b23d0ba 3213 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3214 Event<void(A0, A1, A2)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2) const, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3215 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3216 }
marcozecchini 0:9fca2b23d0ba 3217
marcozecchini 0:9fca2b23d0ba 3218 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3219 Event<void(A0, A1, A2)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2) volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3220 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3221 }
marcozecchini 0:9fca2b23d0ba 3222
marcozecchini 0:9fca2b23d0ba 3223 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3224 Event<void(A0, A1, A2)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2) const volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3225 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3226 }
marcozecchini 0:9fca2b23d0ba 3227
marcozecchini 0:9fca2b23d0ba 3228 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3229 Event<void(A0, A1, A2)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, A0, A1, A2)> cb, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3230 return Event<void(A0, A1, A2)>(this, cb, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3231 }
marcozecchini 0:9fca2b23d0ba 3232
marcozecchini 0:9fca2b23d0ba 3233 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3234 Event<void(A0, A1, A2)> EventQueue::event(R (*func)(B0, B1, B2, B3, B4, A0, A1, A2), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3235 return Event<void(A0, A1, A2)>(this, func, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3236 }
marcozecchini 0:9fca2b23d0ba 3237
marcozecchini 0:9fca2b23d0ba 3238 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3239 Event<void(A0, A1, A2)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3240 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3241 }
marcozecchini 0:9fca2b23d0ba 3242
marcozecchini 0:9fca2b23d0ba 3243 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3244 Event<void(A0, A1, A2)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2) const, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3245 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3246 }
marcozecchini 0:9fca2b23d0ba 3247
marcozecchini 0:9fca2b23d0ba 3248 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3249 Event<void(A0, A1, A2)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2) volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3250 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3251 }
marcozecchini 0:9fca2b23d0ba 3252
marcozecchini 0:9fca2b23d0ba 3253 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3254 Event<void(A0, A1, A2)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2) const volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3255 return Event<void(A0, A1, A2)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3256 }
marcozecchini 0:9fca2b23d0ba 3257
marcozecchini 0:9fca2b23d0ba 3258 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2>
marcozecchini 0:9fca2b23d0ba 3259 Event<void(A0, A1, A2)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, B4, A0, A1, A2)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3260 return Event<void(A0, A1, A2)>(this, cb, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3261 }
marcozecchini 0:9fca2b23d0ba 3262
marcozecchini 0:9fca2b23d0ba 3263 template <typename R, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3264 Event<void(A0, A1, A2, A3)> EventQueue::event(R (*func)(A0, A1, A2, A3)) {
marcozecchini 0:9fca2b23d0ba 3265 return Event<void(A0, A1, A2, A3)>(this, func);
marcozecchini 0:9fca2b23d0ba 3266 }
marcozecchini 0:9fca2b23d0ba 3267
marcozecchini 0:9fca2b23d0ba 3268 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3269 Event<void(A0, A1, A2, A3)> EventQueue::event(T *obj, R (T::*method)(A0, A1, A2, A3)) {
marcozecchini 0:9fca2b23d0ba 3270 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3271 }
marcozecchini 0:9fca2b23d0ba 3272
marcozecchini 0:9fca2b23d0ba 3273 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3274 Event<void(A0, A1, A2, A3)> EventQueue::event(const T *obj, R (T::*method)(A0, A1, A2, A3) const) {
marcozecchini 0:9fca2b23d0ba 3275 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3276 }
marcozecchini 0:9fca2b23d0ba 3277
marcozecchini 0:9fca2b23d0ba 3278 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3279 Event<void(A0, A1, A2, A3)> EventQueue::event(volatile T *obj, R (T::*method)(A0, A1, A2, A3) volatile) {
marcozecchini 0:9fca2b23d0ba 3280 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3281 }
marcozecchini 0:9fca2b23d0ba 3282
marcozecchini 0:9fca2b23d0ba 3283 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3284 Event<void(A0, A1, A2, A3)> EventQueue::event(const volatile T *obj, R (T::*method)(A0, A1, A2, A3) const volatile) {
marcozecchini 0:9fca2b23d0ba 3285 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3286 }
marcozecchini 0:9fca2b23d0ba 3287
marcozecchini 0:9fca2b23d0ba 3288 template <typename R, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3289 Event<void(A0, A1, A2, A3)> EventQueue::event(mbed::Callback<R(A0, A1, A2, A3)> cb) {
marcozecchini 0:9fca2b23d0ba 3290 return Event<void(A0, A1, A2, A3)>(this, cb);
marcozecchini 0:9fca2b23d0ba 3291 }
marcozecchini 0:9fca2b23d0ba 3292
marcozecchini 0:9fca2b23d0ba 3293 template <typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3294 Event<void(A0, A1, A2, A3)> EventQueue::event(R (*func)(B0, A0, A1, A2, A3), C0 c0) {
marcozecchini 0:9fca2b23d0ba 3295 return Event<void(A0, A1, A2, A3)>(this, func, c0);
marcozecchini 0:9fca2b23d0ba 3296 }
marcozecchini 0:9fca2b23d0ba 3297
marcozecchini 0:9fca2b23d0ba 3298 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3299 Event<void(A0, A1, A2, A3)> EventQueue::event(T *obj, R (T::*method)(B0, A0, A1, A2, A3), C0 c0) {
marcozecchini 0:9fca2b23d0ba 3300 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3301 }
marcozecchini 0:9fca2b23d0ba 3302
marcozecchini 0:9fca2b23d0ba 3303 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3304 Event<void(A0, A1, A2, A3)> EventQueue::event(const T *obj, R (T::*method)(B0, A0, A1, A2, A3) const, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3305 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3306 }
marcozecchini 0:9fca2b23d0ba 3307
marcozecchini 0:9fca2b23d0ba 3308 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3309 Event<void(A0, A1, A2, A3)> EventQueue::event(volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3) volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3310 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3311 }
marcozecchini 0:9fca2b23d0ba 3312
marcozecchini 0:9fca2b23d0ba 3313 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3314 Event<void(A0, A1, A2, A3)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3) const volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3315 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3316 }
marcozecchini 0:9fca2b23d0ba 3317
marcozecchini 0:9fca2b23d0ba 3318 template <typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3319 Event<void(A0, A1, A2, A3)> EventQueue::event(mbed::Callback<R(B0, A0, A1, A2, A3)> cb, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3320 return Event<void(A0, A1, A2, A3)>(this, cb, c0);
marcozecchini 0:9fca2b23d0ba 3321 }
marcozecchini 0:9fca2b23d0ba 3322
marcozecchini 0:9fca2b23d0ba 3323 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3324 Event<void(A0, A1, A2, A3)> EventQueue::event(R (*func)(B0, B1, A0, A1, A2, A3), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3325 return Event<void(A0, A1, A2, A3)>(this, func, c0, c1);
marcozecchini 0:9fca2b23d0ba 3326 }
marcozecchini 0:9fca2b23d0ba 3327
marcozecchini 0:9fca2b23d0ba 3328 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3329 Event<void(A0, A1, A2, A3)> EventQueue::event(T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3330 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3331 }
marcozecchini 0:9fca2b23d0ba 3332
marcozecchini 0:9fca2b23d0ba 3333 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3334 Event<void(A0, A1, A2, A3)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3) const, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3335 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3336 }
marcozecchini 0:9fca2b23d0ba 3337
marcozecchini 0:9fca2b23d0ba 3338 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3339 Event<void(A0, A1, A2, A3)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3) volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3340 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3341 }
marcozecchini 0:9fca2b23d0ba 3342
marcozecchini 0:9fca2b23d0ba 3343 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3344 Event<void(A0, A1, A2, A3)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3) const volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3345 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3346 }
marcozecchini 0:9fca2b23d0ba 3347
marcozecchini 0:9fca2b23d0ba 3348 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3349 Event<void(A0, A1, A2, A3)> EventQueue::event(mbed::Callback<R(B0, B1, A0, A1, A2, A3)> cb, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3350 return Event<void(A0, A1, A2, A3)>(this, cb, c0, c1);
marcozecchini 0:9fca2b23d0ba 3351 }
marcozecchini 0:9fca2b23d0ba 3352
marcozecchini 0:9fca2b23d0ba 3353 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3354 Event<void(A0, A1, A2, A3)> EventQueue::event(R (*func)(B0, B1, B2, A0, A1, A2, A3), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3355 return Event<void(A0, A1, A2, A3)>(this, func, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3356 }
marcozecchini 0:9fca2b23d0ba 3357
marcozecchini 0:9fca2b23d0ba 3358 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3359 Event<void(A0, A1, A2, A3)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3360 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3361 }
marcozecchini 0:9fca2b23d0ba 3362
marcozecchini 0:9fca2b23d0ba 3363 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3364 Event<void(A0, A1, A2, A3)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3) const, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3365 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3366 }
marcozecchini 0:9fca2b23d0ba 3367
marcozecchini 0:9fca2b23d0ba 3368 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3369 Event<void(A0, A1, A2, A3)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3) volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3370 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3371 }
marcozecchini 0:9fca2b23d0ba 3372
marcozecchini 0:9fca2b23d0ba 3373 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3374 Event<void(A0, A1, A2, A3)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3) const volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3375 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3376 }
marcozecchini 0:9fca2b23d0ba 3377
marcozecchini 0:9fca2b23d0ba 3378 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3379 Event<void(A0, A1, A2, A3)> EventQueue::event(mbed::Callback<R(B0, B1, B2, A0, A1, A2, A3)> cb, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3380 return Event<void(A0, A1, A2, A3)>(this, cb, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3381 }
marcozecchini 0:9fca2b23d0ba 3382
marcozecchini 0:9fca2b23d0ba 3383 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3384 Event<void(A0, A1, A2, A3)> EventQueue::event(R (*func)(B0, B1, B2, B3, A0, A1, A2, A3), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3385 return Event<void(A0, A1, A2, A3)>(this, func, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3386 }
marcozecchini 0:9fca2b23d0ba 3387
marcozecchini 0:9fca2b23d0ba 3388 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3389 Event<void(A0, A1, A2, A3)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3390 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3391 }
marcozecchini 0:9fca2b23d0ba 3392
marcozecchini 0:9fca2b23d0ba 3393 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3394 Event<void(A0, A1, A2, A3)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3) const, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3395 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3396 }
marcozecchini 0:9fca2b23d0ba 3397
marcozecchini 0:9fca2b23d0ba 3398 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3399 Event<void(A0, A1, A2, A3)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3) volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3400 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3401 }
marcozecchini 0:9fca2b23d0ba 3402
marcozecchini 0:9fca2b23d0ba 3403 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3404 Event<void(A0, A1, A2, A3)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3) const volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3405 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3406 }
marcozecchini 0:9fca2b23d0ba 3407
marcozecchini 0:9fca2b23d0ba 3408 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3409 Event<void(A0, A1, A2, A3)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, A0, A1, A2, A3)> cb, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3410 return Event<void(A0, A1, A2, A3)>(this, cb, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3411 }
marcozecchini 0:9fca2b23d0ba 3412
marcozecchini 0:9fca2b23d0ba 3413 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3414 Event<void(A0, A1, A2, A3)> EventQueue::event(R (*func)(B0, B1, B2, B3, B4, A0, A1, A2, A3), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3415 return Event<void(A0, A1, A2, A3)>(this, func, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3416 }
marcozecchini 0:9fca2b23d0ba 3417
marcozecchini 0:9fca2b23d0ba 3418 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3419 Event<void(A0, A1, A2, A3)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3420 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3421 }
marcozecchini 0:9fca2b23d0ba 3422
marcozecchini 0:9fca2b23d0ba 3423 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3424 Event<void(A0, A1, A2, A3)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3) const, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3425 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3426 }
marcozecchini 0:9fca2b23d0ba 3427
marcozecchini 0:9fca2b23d0ba 3428 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3429 Event<void(A0, A1, A2, A3)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3) volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3430 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3431 }
marcozecchini 0:9fca2b23d0ba 3432
marcozecchini 0:9fca2b23d0ba 3433 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3434 Event<void(A0, A1, A2, A3)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3) const volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3435 return Event<void(A0, A1, A2, A3)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3436 }
marcozecchini 0:9fca2b23d0ba 3437
marcozecchini 0:9fca2b23d0ba 3438 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3>
marcozecchini 0:9fca2b23d0ba 3439 Event<void(A0, A1, A2, A3)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, B4, A0, A1, A2, A3)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3440 return Event<void(A0, A1, A2, A3)>(this, cb, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3441 }
marcozecchini 0:9fca2b23d0ba 3442
marcozecchini 0:9fca2b23d0ba 3443 template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3444 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(R (*func)(A0, A1, A2, A3, A4)) {
marcozecchini 0:9fca2b23d0ba 3445 return Event<void(A0, A1, A2, A3, A4)>(this, func);
marcozecchini 0:9fca2b23d0ba 3446 }
marcozecchini 0:9fca2b23d0ba 3447
marcozecchini 0:9fca2b23d0ba 3448 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3449 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(T *obj, R (T::*method)(A0, A1, A2, A3, A4)) {
marcozecchini 0:9fca2b23d0ba 3450 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3451 }
marcozecchini 0:9fca2b23d0ba 3452
marcozecchini 0:9fca2b23d0ba 3453 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3454 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const T *obj, R (T::*method)(A0, A1, A2, A3, A4) const) {
marcozecchini 0:9fca2b23d0ba 3455 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3456 }
marcozecchini 0:9fca2b23d0ba 3457
marcozecchini 0:9fca2b23d0ba 3458 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3459 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) volatile) {
marcozecchini 0:9fca2b23d0ba 3460 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3461 }
marcozecchini 0:9fca2b23d0ba 3462
marcozecchini 0:9fca2b23d0ba 3463 template <typename T, typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3464 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const volatile T *obj, R (T::*method)(A0, A1, A2, A3, A4) const volatile) {
marcozecchini 0:9fca2b23d0ba 3465 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method));
marcozecchini 0:9fca2b23d0ba 3466 }
marcozecchini 0:9fca2b23d0ba 3467
marcozecchini 0:9fca2b23d0ba 3468 template <typename R, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3469 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(mbed::Callback<R(A0, A1, A2, A3, A4)> cb) {
marcozecchini 0:9fca2b23d0ba 3470 return Event<void(A0, A1, A2, A3, A4)>(this, cb);
marcozecchini 0:9fca2b23d0ba 3471 }
marcozecchini 0:9fca2b23d0ba 3472
marcozecchini 0:9fca2b23d0ba 3473 template <typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3474 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(R (*func)(B0, A0, A1, A2, A3, A4), C0 c0) {
marcozecchini 0:9fca2b23d0ba 3475 return Event<void(A0, A1, A2, A3, A4)>(this, func, c0);
marcozecchini 0:9fca2b23d0ba 3476 }
marcozecchini 0:9fca2b23d0ba 3477
marcozecchini 0:9fca2b23d0ba 3478 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3479 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4), C0 c0) {
marcozecchini 0:9fca2b23d0ba 3480 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3481 }
marcozecchini 0:9fca2b23d0ba 3482
marcozecchini 0:9fca2b23d0ba 3483 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3484 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4) const, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3485 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3486 }
marcozecchini 0:9fca2b23d0ba 3487
marcozecchini 0:9fca2b23d0ba 3488 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3489 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4) volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3490 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3491 }
marcozecchini 0:9fca2b23d0ba 3492
marcozecchini 0:9fca2b23d0ba 3493 template <typename T, typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3494 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, A0, A1, A2, A3, A4) const volatile, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3495 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0);
marcozecchini 0:9fca2b23d0ba 3496 }
marcozecchini 0:9fca2b23d0ba 3497
marcozecchini 0:9fca2b23d0ba 3498 template <typename R, typename B0, typename C0, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3499 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(mbed::Callback<R(B0, A0, A1, A2, A3, A4)> cb, C0 c0) {
marcozecchini 0:9fca2b23d0ba 3500 return Event<void(A0, A1, A2, A3, A4)>(this, cb, c0);
marcozecchini 0:9fca2b23d0ba 3501 }
marcozecchini 0:9fca2b23d0ba 3502
marcozecchini 0:9fca2b23d0ba 3503 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3504 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(R (*func)(B0, B1, A0, A1, A2, A3, A4), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3505 return Event<void(A0, A1, A2, A3, A4)>(this, func, c0, c1);
marcozecchini 0:9fca2b23d0ba 3506 }
marcozecchini 0:9fca2b23d0ba 3507
marcozecchini 0:9fca2b23d0ba 3508 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3509 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4), C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3510 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3511 }
marcozecchini 0:9fca2b23d0ba 3512
marcozecchini 0:9fca2b23d0ba 3513 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3514 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4) const, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3515 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3516 }
marcozecchini 0:9fca2b23d0ba 3517
marcozecchini 0:9fca2b23d0ba 3518 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3519 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4) volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3520 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3521 }
marcozecchini 0:9fca2b23d0ba 3522
marcozecchini 0:9fca2b23d0ba 3523 template <typename T, typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3524 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, A0, A1, A2, A3, A4) const volatile, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3525 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1);
marcozecchini 0:9fca2b23d0ba 3526 }
marcozecchini 0:9fca2b23d0ba 3527
marcozecchini 0:9fca2b23d0ba 3528 template <typename R, typename B0, typename B1, typename C0, typename C1, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3529 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(mbed::Callback<R(B0, B1, A0, A1, A2, A3, A4)> cb, C0 c0, C1 c1) {
marcozecchini 0:9fca2b23d0ba 3530 return Event<void(A0, A1, A2, A3, A4)>(this, cb, c0, c1);
marcozecchini 0:9fca2b23d0ba 3531 }
marcozecchini 0:9fca2b23d0ba 3532
marcozecchini 0:9fca2b23d0ba 3533 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3534 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(R (*func)(B0, B1, B2, A0, A1, A2, A3, A4), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3535 return Event<void(A0, A1, A2, A3, A4)>(this, func, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3536 }
marcozecchini 0:9fca2b23d0ba 3537
marcozecchini 0:9fca2b23d0ba 3538 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3539 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4), C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3540 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3541 }
marcozecchini 0:9fca2b23d0ba 3542
marcozecchini 0:9fca2b23d0ba 3543 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3544 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4) const, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3545 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3546 }
marcozecchini 0:9fca2b23d0ba 3547
marcozecchini 0:9fca2b23d0ba 3548 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3549 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4) volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3550 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3551 }
marcozecchini 0:9fca2b23d0ba 3552
marcozecchini 0:9fca2b23d0ba 3553 template <typename T, typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3554 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, A0, A1, A2, A3, A4) const volatile, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3555 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3556 }
marcozecchini 0:9fca2b23d0ba 3557
marcozecchini 0:9fca2b23d0ba 3558 template <typename R, typename B0, typename B1, typename B2, typename C0, typename C1, typename C2, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3559 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(mbed::Callback<R(B0, B1, B2, A0, A1, A2, A3, A4)> cb, C0 c0, C1 c1, C2 c2) {
marcozecchini 0:9fca2b23d0ba 3560 return Event<void(A0, A1, A2, A3, A4)>(this, cb, c0, c1, c2);
marcozecchini 0:9fca2b23d0ba 3561 }
marcozecchini 0:9fca2b23d0ba 3562
marcozecchini 0:9fca2b23d0ba 3563 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3564 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(R (*func)(B0, B1, B2, B3, A0, A1, A2, A3, A4), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3565 return Event<void(A0, A1, A2, A3, A4)>(this, func, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3566 }
marcozecchini 0:9fca2b23d0ba 3567
marcozecchini 0:9fca2b23d0ba 3568 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3569 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4), C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3570 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3571 }
marcozecchini 0:9fca2b23d0ba 3572
marcozecchini 0:9fca2b23d0ba 3573 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3574 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4) const, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3575 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3576 }
marcozecchini 0:9fca2b23d0ba 3577
marcozecchini 0:9fca2b23d0ba 3578 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3579 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4) volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3580 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3581 }
marcozecchini 0:9fca2b23d0ba 3582
marcozecchini 0:9fca2b23d0ba 3583 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3584 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, A0, A1, A2, A3, A4) const volatile, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3585 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3586 }
marcozecchini 0:9fca2b23d0ba 3587
marcozecchini 0:9fca2b23d0ba 3588 template <typename R, typename B0, typename B1, typename B2, typename B3, typename C0, typename C1, typename C2, typename C3, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3589 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, A0, A1, A2, A3, A4)> cb, C0 c0, C1 c1, C2 c2, C3 c3) {
marcozecchini 0:9fca2b23d0ba 3590 return Event<void(A0, A1, A2, A3, A4)>(this, cb, c0, c1, c2, c3);
marcozecchini 0:9fca2b23d0ba 3591 }
marcozecchini 0:9fca2b23d0ba 3592
marcozecchini 0:9fca2b23d0ba 3593 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3594 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(R (*func)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3595 return Event<void(A0, A1, A2, A3, A4)>(this, func, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3596 }
marcozecchini 0:9fca2b23d0ba 3597
marcozecchini 0:9fca2b23d0ba 3598 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3599 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4), C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3600 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3601 }
marcozecchini 0:9fca2b23d0ba 3602
marcozecchini 0:9fca2b23d0ba 3603 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3604 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4) const, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3605 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3606 }
marcozecchini 0:9fca2b23d0ba 3607
marcozecchini 0:9fca2b23d0ba 3608 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3609 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4) volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3610 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3611 }
marcozecchini 0:9fca2b23d0ba 3612
marcozecchini 0:9fca2b23d0ba 3613 template <typename T, typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3614 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(const volatile T *obj, R (T::*method)(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4) const volatile, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3615 return Event<void(A0, A1, A2, A3, A4)>(this, mbed::callback(obj, method), c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3616 }
marcozecchini 0:9fca2b23d0ba 3617
marcozecchini 0:9fca2b23d0ba 3618 template <typename R, typename B0, typename B1, typename B2, typename B3, typename B4, typename C0, typename C1, typename C2, typename C3, typename C4, typename A0, typename A1, typename A2, typename A3, typename A4>
marcozecchini 0:9fca2b23d0ba 3619 Event<void(A0, A1, A2, A3, A4)> EventQueue::event(mbed::Callback<R(B0, B1, B2, B3, B4, A0, A1, A2, A3, A4)> cb, C0 c0, C1 c1, C2 c2, C3 c3, C4 c4) {
marcozecchini 0:9fca2b23d0ba 3620 return Event<void(A0, A1, A2, A3, A4)>(this, cb, c0, c1, c2, c3, c4);
marcozecchini 0:9fca2b23d0ba 3621 }
marcozecchini 0:9fca2b23d0ba 3622
marcozecchini 0:9fca2b23d0ba 3623 }
marcozecchini 0:9fca2b23d0ba 3624
marcozecchini 0:9fca2b23d0ba 3625 #endif
marcozecchini 0:9fca2b23d0ba 3626
marcozecchini 0:9fca2b23d0ba 3627 /** @}*/