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

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