21 #include "events/EventQueue.h" 22 #include "drivers/internal/TaskBase.h" 23 #include "platform/mbed_assert.h" 24 #include "platform/Callback.h" 32 template<
typename F,
typename A1 =
void,
typename A2 =
void,
typename A3 =
void,
typename A4 =
void,
typename A5 =
void>
40 AllArgs(B0 b0 = B0()): b0(b0) {}
42 template <
typename T,
typename _>
44 static void copy(
void *_dest,
void *_src)
46 new (_dest) Self(*(Self *)_src);
49 static void call(
void *data)
51 Self *s =
static_cast<Self *
>(data);
57 typedef Operations<B0, void> ops;
60 template<
typename B0,
typename B1>
66 AllArgs(B0 b0 = B0(), B1 b1 = B1()): b0(b0), b1(b1) {}
68 template <
typename T,
typename _>
70 static void copy(
void *_dest,
void *_src)
72 new (_dest) Self(*(Self *)_src);
75 static void call(
void *data)
77 Self *s =
static_cast<Self *
>(data);
83 template <
typename T,
typename R,
typename U>
84 struct Operations<T *, R(U::*)()> {
85 static void copy(
void *_dest,
void *_src)
87 new (_dest) Self(*(Self *)_src);
90 static void call(
void *data)
92 Self *s =
static_cast<Self *
>(data);
93 ((s->b0)->*(s->b1))();
98 template <
typename T,
typename R,
typename U>
99 struct Operations<T, R(U::*)() const> {
100 static void copy(
void *_dest,
void *_src)
102 new (_dest) Self(*(Self *)_src);
105 static void call(
void *data)
107 Self *s =
static_cast<Self *
>(data);
108 ((s->b0)->*(s->b1))();
113 template <
typename T,
typename R,
typename U>
114 struct Operations<T, R(U::*)() volatile> {
115 static void copy(
void *_dest,
void *_src)
117 new (_dest) Self(*(Self *)_src);
120 static void call(
void *data)
122 Self *s =
static_cast<Self *
>(data);
123 ((s->b0)->*(s->b1))();
128 template <
typename T,
typename R,
typename U>
129 struct Operations<T, R(U::*)() const volatile> {
130 static void copy(
void *_dest,
void *_src)
132 new (_dest) Self(*(Self *)_src);
135 static void call(
void *data)
137 Self *s =
static_cast<Self *
>(data);
138 ((s->b0)->*(s->b1))();
143 typedef Operations<B0, B1> ops;
146 template<
typename B0,
typename B1,
typename B2>
154 AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2()): b0(b0), b1(b1), b2(b2) {}
156 template <
typename T,
typename _>
158 static void copy(
void *_dest,
void *_src)
160 new (_dest) Self(*(Self *)_src);
163 static void call(
void *data)
165 Self *s =
static_cast<Self *
>(data);
171 template <
typename T,
typename R,
typename U>
172 struct Operations<T *, R(U::*)(B2)> {
173 static void copy(
void *_dest,
void *_src)
175 new (_dest) Self(*(Self *)_src);
178 static void call(
void *data)
180 Self *s =
static_cast<Self *
>(data);
181 ((s->b0)->*(s->b1))(s->b2);
186 template <
typename T,
typename R,
typename U>
187 struct Operations<T, R(U::*)(B2) const> {
188 static void copy(
void *_dest,
void *_src)
190 new (_dest) Self(*(Self *)_src);
193 static void call(
void *data)
195 Self *s =
static_cast<Self *
>(data);
196 ((s->b0)->*(s->b1))(s->b2);
201 template <
typename T,
typename R,
typename U>
202 struct Operations<T, R(U::*)(B2) volatile> {
203 static void copy(
void *_dest,
void *_src)
205 new (_dest) Self(*(Self *)_src);
208 static void call(
void *data)
210 Self *s =
static_cast<Self *
>(data);
211 ((s->b0)->*(s->b1))(s->b2);
216 template <
typename T,
typename R,
typename U>
217 struct Operations<T, R(U::*)(B2) const volatile> {
218 static void copy(
void *_dest,
void *_src)
220 new (_dest) Self(*(Self *)_src);
223 static void call(
void *data)
225 Self *s =
static_cast<Self *
>(data);
226 ((s->b0)->*(s->b1))(s->b2);
231 typedef Operations<B0, B1> ops;
234 template<
typename B0,
typename B1,
typename B2,
typename B3>
243 AllArgs(B0 b0 = B0(), B1 b1 = B1(), B2 b2 = B2(), B3 b3 = B3()): b0(b0), b1(b1), b2(b2), b3(b3) {}
245 template <
typename T,
typename _>
247 static void copy(
void *_dest,
void *_src)
249 new (_dest) Self(*(Self *)_src);
252 static void call(
void *data)
254 Self *s =
static_cast<Self *
>(data);
255 s->b0(s->b1, s->b2, s->b3);
260 template <
typename T,
typename R,
typename U>
261 struct Operations<T *, R(U::*)(B2, B3)> {
262 static void copy(
void *_dest,
void *_src)
264 new (_dest) Self(*(Self *)_src);
267 static void call(
void *data)
269 Self *s =
static_cast<Self *
>(data);
270 ((s->b0)->*(s->b1))(s->b2, s->b3);
275 template <
typename T,
typename R,
typename U>
276 struct Operations<T, R(U::*)(B2, B3) const> {
277 static void copy(
void *_dest,
void *_src)
279 new (_dest) Self(*(Self *)_src);
282 static void call(
void *data)
284 Self *s =
static_cast<Self *
>(data);
285 ((s->b0)->*(s->b1))(s->b2, s->b3);
290 template <
typename T,
typename R,
typename U>
291 struct Operations<T, R(U::*)(B2, B3) volatile> {
292 static void copy(
void *_dest,
void *_src)
294 new (_dest) Self(*(Self *)_src);
297 static void call(
void *data)
299 Self *s =
static_cast<Self *
>(data);
300 ((s->b0)->*(s->b1))(s->b2, s->b3);
305 template <
typename T,
typename R,
typename U>
306 struct Operations<T, R(U::*)(B2, B3) const volatile> {
307 static void copy(
void *_dest,
void *_src)
309 new (_dest) Self(*(Self *)_src);
312 static void call(
void *data)
314 Self *s =
static_cast<Self *
>(data);
315 ((s->b0)->*(s->b1))(s->b2, s->b3);
320 typedef Operations<B0, B1> ops;
323 template<
typename B0,
typename B1,
typename B2,
typename B3,
typename B4>
333 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) {}
335 template <
typename T,
typename _>
337 static void copy(
void *_dest,
void *_src)
339 new (_dest) Self(*(Self *)_src);
342 static void call(
void *data)
344 Self *s =
static_cast<Self *
>(data);
345 s->b0(s->b1, s->b2, s->b3, s->b4);
350 template <
typename T,
typename R,
typename U>
351 struct Operations<T *, R(U::*)(B2, B3, B4)> {
352 static void copy(
void *_dest,
void *_src)
354 new (_dest) Self(*(Self *)_src);
357 static void call(
void *data)
359 Self *s =
static_cast<Self *
>(data);
360 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
365 template <
typename T,
typename R,
typename U>
366 struct Operations<T, R(U::*)(B2, B3, B4) const> {
367 static void copy(
void *_dest,
void *_src)
369 new (_dest) Self(*(Self *)_src);
372 static void call(
void *data)
374 Self *s =
static_cast<Self *
>(data);
375 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
380 template <
typename T,
typename R,
typename U>
381 struct Operations<T, R(U::*)(B2, B3, B4) volatile> {
382 static void copy(
void *_dest,
void *_src)
384 new (_dest) Self(*(Self *)_src);
387 static void call(
void *data)
389 Self *s =
static_cast<Self *
>(data);
390 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
395 template <
typename T,
typename R,
typename U>
396 struct Operations<T, R(U::*)(B2, B3, B4) const volatile> {
397 static void copy(
void *_dest,
void *_src)
399 new (_dest) Self(*(Self *)_src);
402 static void call(
void *data)
404 Self *s =
static_cast<Self *
>(data);
405 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4);
410 typedef Operations<B0, B1> ops;
413 template<
typename B0,
typename B1,
typename B2,
typename B3,
typename B4,
typename B5>
424 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) {}
426 template <
typename T,
typename _>
428 static void copy(
void *_dest,
void *_src)
430 new (_dest) Self(*(Self *)_src);
433 static void call(
void *data)
435 Self *s =
static_cast<Self *
>(data);
436 s->b0(s->b1, s->b2, s->b3, s->b4, s->b5);
441 template <
typename T,
typename R,
typename U>
443 static void copy(
void *_dest,
void *_src)
445 new (_dest) Self(*(Self *)_src);
448 static void call(
void *data)
450 Self *s =
static_cast<Self *
>(data);
451 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
456 template <
typename T,
typename R,
typename U>
458 static void copy(
void *_dest,
void *_src)
460 new (_dest) Self(*(Self *)_src);
463 static void call(
void *data)
465 Self *s =
static_cast<Self *
>(data);
466 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
471 template <
typename T,
typename R,
typename U>
473 static void copy(
void *_dest,
void *_src)
475 new (_dest) Self(*(Self *)_src);
478 static void call(
void *data)
480 Self *s =
static_cast<Self *
>(data);
481 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
486 template <
typename T,
typename R,
typename U>
487 struct Operations<T, R(U::*)(B2, B3, B4, B5) const volatile> {
488 static void copy(
void *_dest,
void *_src)
490 new (_dest) Self(*(Self *)_src);
493 static void call(
void *data)
495 Self *s =
static_cast<Self *
>(data);
496 ((s->b0)->*(s->b1))(s->b2, s->b3, s->b4, s->b5);
505 template <
typename F>
508 template <
typename R>
532 return sizeof(_args);
535 virtual run_callback_t
start(
void *data, uint32_t max_size)
537 All::ops::copy(data, (
void *)&_args);
538 return &All::ops::call;
546 template <
typename R,
typename A0>
571 return sizeof(_args);
574 virtual run_callback_t
start(
void *data, uint32_t max_size)
576 All::ops::copy(data, (
void *)&_args);
577 return &All::ops::call;
589 template <
typename R,
typename A0,
typename A1>
637 return sizeof(_args);
640 virtual run_callback_t
start(
void *data, uint32_t max_size)
642 All::ops::copy(data, (
void *)&_args);
643 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.