21 #include "events/EventQueue.h"    22 #include "events/TaskBase.h"    23 #include "platform/mbed_assert.h"    24 #include "platform/Callback.h"    30 template<
typename F, 
typename A1 = 
void, 
typename A2 = 
void, 
typename A3 = 
void, 
typename A4 = 
void, 
typename A5 = 
void>
    38     AllArgs(B0 b0 = B0()): b0(b0) {}
    40     template <
typename T, 
typename _>
    42         static void copy(
void *_dest, 
void *_src)
    44             new (_dest) Self(*(Self *)_src);
    47         static void call(
void *data)
    49             Self *s = 
static_cast<Self *
>(data);
    55     typedef Operations<B0, void> ops;
    58 template<
typename B0, 
typename B1>
    64     AllArgs(B0 b0 = B0(), B1 b1 = B1()): b0(b0), b1(b1) {}
    66     template <
typename T, 
typename _>
    68         static void copy(
void *_dest, 
void *_src)
    70             new (_dest) Self(*(Self *)_src);
    73         static void call(
void *data)
    75             Self *s = 
static_cast<Self *
>(data);
    81     template <
typename T, 
typename R, 
typename U>
    82     struct Operations<T *, R(U::*)()> {
    83         static void copy(
void *_dest, 
void *_src)
    85             new (_dest) Self(*(Self *)_src);
    88         static void call(
void *data)
    90             Self *s = 
static_cast<Self *
>(data);
    91             ((s->b0)->*(s->b1))();
    96     template <
typename T, 
typename R, 
typename U>
    97     struct Operations<T, R(U::*)() const> {
    98         static void copy(
void *_dest, 
void *_src)
   100             new (_dest) Self(*(Self *)_src);
   103         static void call(
void *data)
   105             Self *s = 
static_cast<Self *
>(data);
   106             ((s->b0)->*(s->b1))();
   111     template <
typename T, 
typename R, 
typename U>
   112     struct Operations<T, R(U::*)() volatile> {
   113         static void copy(
void *_dest, 
void *_src)
   115             new (_dest) Self(*(Self *)_src);
   118         static void call(
void *data)
   120             Self *s = 
static_cast<Self *
>(data);
   121             ((s->b0)->*(s->b1))();
   126     template <
typename T, 
typename R, 
typename U>
   127     struct Operations<T, R(U::*)() const volatile> {
   128         static void copy(
void *_dest, 
void *_src)
   130             new (_dest) Self(*(Self *)_src);
   133         static void call(
void *data)
   135             Self *s = 
static_cast<Self *
>(data);
   136             ((s->b0)->*(s->b1))();
   141     typedef Operations<B0, B1> ops;
   144 template<
typename B0, 
typename B1, 
typename B2>
   152     AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2()): b0(b0), b1(b1), b2(b2) {}
   154     template <
typename T, 
typename _>
   156         static void copy(
void *_dest, 
void *_src)
   158             new (_dest) Self(*(Self *)_src);
   161         static void call(
void *data)
   163             Self *s = 
static_cast<Self *
>(data);
   169     template <
typename T, 
typename R, 
typename U>
   170     struct Operations<T *, R(U::*)(B2)> {
   171         static void copy(
void *_dest, 
void *_src)
   173             new (_dest) Self(*(Self *)_src);
   176         static void call(
void *data)
   178             Self *s = 
static_cast<Self *
>(data);
   179             ((s->b0)->*(s->b1))(s->b2);
   184     template <
typename T, 
typename R, 
typename U>
   185     struct Operations<T, R(U::*)(B2) const> {
   186         static void copy(
void *_dest, 
void *_src)
   188             new (_dest) Self(*(Self *)_src);
   191         static void call(
void *data)
   193             Self *s = 
static_cast<Self *
>(data);
   194             ((s->b0)->*(s->b1))(s->b2);
   199     template <
typename T, 
typename R, 
typename U>
   200     struct Operations<T, R(U::*)(B2) volatile> {
   201         static void copy(
void *_dest, 
void *_src)
   203             new (_dest) Self(*(Self *)_src);
   206         static void call(
void *data)
   208             Self *s = 
static_cast<Self *
>(data);
   209             ((s->b0)->*(s->b1))(s->b2);
   214     template <
typename T, 
typename R, 
typename U>
   215     struct Operations<T, R(U::*)(B2) const volatile> {
   216         static void copy(
void *_dest, 
void *_src)
   218             new (_dest) Self(*(Self *)_src);
   221         static void call(
void *data)
   223             Self *s = 
static_cast<Self *
>(data);
   224             ((s->b0)->*(s->b1))(s->b2);
   229     typedef Operations<B0, B1> ops;
   232 template<
typename B0, 
typename B1, 
typename B2, 
typename B3>
   241     AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3()): b0(b0), b1(b1), b2(b2), b3(b3) {}
   243     template <
typename T, 
typename _>
   245         static void copy(
void *_dest, 
void *_src)
   247             new (_dest) Self(*(Self *)_src);
   250         static void call(
void *data)
   252             Self *s = 
static_cast<Self *
>(data);
   253             s->b0(s->b1, s->b2, s->b3);
   258     template <
typename T, 
typename R, 
typename U>
   259     struct Operations<T *, R(U::*)(B2, B3)> {
   260         static void copy(
void *_dest, 
void *_src)
   262             new (_dest) Self(*(Self *)_src);
   265         static void call(
void *data)
   267             Self *s = 
static_cast<Self *
>(data);
   268             ((s->b0)->*(s->b1))(s->b2, s->b3);
   273     template <
typename T, 
typename R, 
typename U>
   274     struct Operations<T, R(U::*)(B2, B3) const> {
   275         static void copy(
void *_dest, 
void *_src)
   277             new (_dest) Self(*(Self *)_src);
   280         static void call(
void *data)
   282             Self *s = 
static_cast<Self *
>(data);
   283             ((s->b0)->*(s->b1))(s->b2, s->b3);
   288     template <
typename T, 
typename R, 
typename U>
   289     struct Operations<T, R(U::*)(B2, B3) volatile> {
   290         static void copy(
void *_dest, 
void *_src)
   292             new (_dest) Self(*(Self *)_src);
   295         static void call(
void *data)
   297             Self *s = 
static_cast<Self *
>(data);
   298             ((s->b0)->*(s->b1))(s->b2, s->b3);
   303     template <
typename T, 
typename R, 
typename U>
   304     struct Operations<T, R(U::*)(B2, B3) const volatile> {
   305         static void copy(
void *_dest, 
void *_src)
   307             new (_dest) Self(*(Self *)_src);
   310         static void call(
void *data)
   312             Self *s = 
static_cast<Self *
>(data);
   313             ((s->b0)->*(s->b1))(s->b2, s->b3);
   318     typedef Operations<B0, B1> ops;
   321 template<
typename B0, 
typename B1, 
typename B2, 
typename B3, 
typename B4>
   331     AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3(), B4 b4 = B4()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4) {}
   333     template <
typename T, 
typename _>
   335         static void copy(
void *_dest, 
void *_src)
   337             new (_dest) Self(*(Self *)_src);
   340         static void call(
void *data)
   342             Self *s = 
static_cast<Self *
>(data);
   343             s->b0(s->b1, s->b2, s->b3, s->b4);
   348     template <
typename T, 
typename R, 
typename U>
   349     struct Operations<T *, R(U::*)(B2, B3, B4)> {
   350         static void copy(
void *_dest, 
void *_src)
   352             new (_dest) Self(*(Self *)_src);
   355         static void call(
void *data)
   357             Self *s = 
static_cast<Self *
>(data);
   358             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
   363     template <
typename T, 
typename R, 
typename U>
   364     struct Operations<T, R(U::*)(B2, B3, B4) const> {
   365         static void copy(
void *_dest, 
void *_src)
   367             new (_dest) Self(*(Self *)_src);
   370         static void call(
void *data)
   372             Self *s = 
static_cast<Self *
>(data);
   373             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
   378     template <
typename T, 
typename R, 
typename U>
   379     struct Operations<T, R(U::*)(B2, B3, B4) volatile> {
   380         static void copy(
void *_dest, 
void *_src)
   382             new (_dest) Self(*(Self *)_src);
   385         static void call(
void *data)
   387             Self *s = 
static_cast<Self *
>(data);
   388             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
   393     template <
typename T, 
typename R, 
typename U>
   394     struct Operations<T, R(U::*)(B2, B3, B4) const volatile> {
   395         static void copy(
void *_dest, 
void *_src)
   397             new (_dest) Self(*(Self *)_src);
   400         static void call(
void *data)
   402             Self *s = 
static_cast<Self *
>(data);
   403             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
   408     typedef Operations<B0, B1> ops;
   411 template<
typename B0, 
typename B1, 
typename B2, 
typename B3, 
typename B4, 
typename B5>
   422     AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3(), B4 b4 = B4(), B5 b5 = B5()): b0(b0), b1(b1), b2(b2), b3(b3), b4(b4), b5(b5) {}
   424     template <
typename T, 
typename _>
   426         static void copy(
void *_dest, 
void *_src)
   428             new (_dest) Self(*(Self *)_src);
   431         static void call(
void *data)
   433             Self *s = 
static_cast<Self *
>(data);
   434             s->b0(s->b1, s->b2, s->b3, s->b4, s->b5);
   439     template <
typename T, 
typename R, 
typename U>
   441         static void copy(
void *_dest, 
void *_src)
   443             new (_dest) Self(*(Self *)_src);
   446         static void call(
void *data)
   448             Self *s = 
static_cast<Self *
>(data);
   449             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
   454     template <
typename T, 
typename R, 
typename U>
   456         static void copy(
void *_dest, 
void *_src)
   458             new (_dest) Self(*(Self *)_src);
   461         static void call(
void *data)
   463             Self *s = 
static_cast<Self *
>(data);
   464             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
   469     template <
typename T, 
typename R, 
typename U>
   471         static void copy(
void *_dest, 
void *_src)
   473             new (_dest) Self(*(Self *)_src);
   476         static void call(
void *data)
   478             Self *s = 
static_cast<Self *
>(data);
   479             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
   484     template <
typename T, 
typename R, 
typename U>
   485     struct Operations<T, R(U::*)(B2, B3, B4, B5) const volatile> {
   486         static void copy(
void *_dest, 
void *_src)
   488             new (_dest) Self(*(Self *)_src);
   491         static void call(
void *data)
   493             Self *s = 
static_cast<Self *
>(data);
   494             ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
   503 template <
typename F>
   506 template <
typename R>
   530         return sizeof(_args);
   533     virtual run_callback_t 
start(
void *data, uint32_t max_size)
   535         All::ops::copy(data, (
void *)&_args);
   536         return &All::ops::call;
   544 template <
typename R, 
typename A0>
   569         return sizeof(_args);
   572     virtual run_callback_t 
start(
void *data, uint32_t max_size)
   574         All::ops::copy(data, (
void *)&_args);
   575         return &All::ops::call;
   588 template <
typename R, 
typename A0, 
typename A1>
   636         return sizeof(_args);
   639     virtual run_callback_t 
start(
void *data, uint32_t max_size)
   641         All::ops::copy(data, (
void *)&_args);
   642         return &All::ops::call;
 virtual run_callback_t start(void *data, uint32_t max_size)
Copy any callback data and return a callback to run. 
void call(A0 a0, A1 a1)
Post this task for execution. 
Task(TaskQueue *q=NULL, mbed::Callback< R(A0, A1)> cb=mbed::Callback< R(A0, A1)>())
Construct a new task. 
Task & operator=(mbed::Callback< R(A0, A1)> cb)
Set the callback of this task. 
virtual run_callback_t start(void *data, uint32_t max_size)
Copy any callback data and return a callback to run. 
virtual uint32_t size()
Size of buffer required for TaskBase::start. 
virtual run_callback_t start(void *data, uint32_t max_size)
Copy any callback data and return a callback to run. 
virtual uint32_t size()
Size of buffer required for TaskBase::start. 
Callback class based on template specialization. 
virtual uint32_t size()
Size of buffer required for TaskBase::start.