mbed os with nrf51 internal bandgap enabled to read battery level

Dependents:   BLE_file_test BLE_Blink ExternalEncoder

Committer:
elessair
Date:
Sun Oct 23 15:10:02 2016 +0000
Revision:
0:f269e3021894
Initial commit

Who changed what in which revision?

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