@@ -197,6 +197,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
197
197
* enough memory to allocate the event.
198
198
* Returned id will remain valid until event has finished
199
199
* executing.
200
+ *
201
+ * @code
202
+ * int main() {
203
+ * // creates a queue with the default size
204
+ * EventQueue queue;
205
+ *
206
+ * // events are simple callbacks
207
+ * queue.call(printf, "called immediately\n");
208
+ * queue.call_in(2000, printf, "called in 2 seconds\n");
209
+ * queue.call_every(1000, printf, "called every 1 seconds\n");
210
+ *
211
+ * // events are executed by the dispatch method
212
+ * queue.dispatch();
213
+ * }
214
+ * @endcode
200
215
*/
201
216
template <typename F, typename ...Args>
202
217
int call (F f, Args ...args);
@@ -217,6 +232,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
217
232
* enough memory to allocate the event.
218
233
* Returned id will remain valid until event has finished
219
234
* executing.
235
+ *
236
+ * @code
237
+ * int main() {
238
+ * // creates a queue with the default size
239
+ * EventQueue queue;
240
+ *
241
+ * // events are simple callbacks
242
+ * queue.call(printf, "called immediately\n");
243
+ * queue.call_in(2000, printf, "called in 2 seconds\n");
244
+ * queue.call_every(1000, printf, "called every 1 seconds\n");
245
+ *
246
+ * // events are executed by the dispatch method
247
+ * queue.dispatch();
248
+ * }
249
+ * @endcode
220
250
*/
221
251
template <typename T, typename R, typename ...Args>
222
252
int call (T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -234,6 +264,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
234
264
* @return A unique id that represents the posted event and can
235
265
* be passed to cancel, or an id of 0 if there is not
236
266
* enough memory to allocate the event.
267
+ *
268
+ * @code
269
+ * int main() {
270
+ * // creates a queue with the default size
271
+ * EventQueue queue;
272
+ *
273
+ * // events are simple callbacks
274
+ * queue.call(printf, "called immediately\n");
275
+ * queue.call_in(2000, printf, "called in 2 seconds\n");
276
+ * queue.call_every(1000, printf, "called every 1 seconds\n");
277
+ *
278
+ * // events are executed by the dispatch method
279
+ * queue.dispatch();
280
+ * }
281
+ * @endcode
237
282
*/
238
283
template <typename F, typename ...Args>
239
284
int call_in (int ms, Args ...args);
@@ -253,6 +298,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
253
298
* @return A unique id that represents the posted event and can
254
299
* be passed to cancel, or an id of 0 if there is not
255
300
* enough memory to allocate the event.
301
+ *
302
+ * @code
303
+ * int main() {
304
+ * // creates a queue with the default size
305
+ * EventQueue queue;
306
+ *
307
+ * // events are simple callbacks
308
+ * queue.call(printf, "called immediately\n");
309
+ * queue.call_in(2000, printf, "called in 2 seconds\n");
310
+ * queue.call_every(1000, printf, "called every 1 seconds\n");
311
+ *
312
+ * // events are executed by the dispatch method
313
+ * queue.dispatch();
314
+ * }
315
+ * @endcode
256
316
*/
257
317
template <typename T, typename R, typename ...Args>
258
318
int call_in (int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -274,6 +334,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
274
334
* @return A unique id that represents the posted event and can
275
335
* be passed to cancel, or an id of 0 if there is not
276
336
* enough memory to allocate the event.
337
+ *
338
+ * @code
339
+ * int main() {
340
+ * // creates a queue with the default size
341
+ * EventQueue queue;
342
+ *
343
+ * // events are simple callbacks
344
+ * queue.call(printf, "called immediately\n");
345
+ * queue.call_in(2000, printf, "called in 2 seconds\n");
346
+ * queue.call_every(1000, printf, "called every 1 seconds\n");
347
+ *
348
+ * // events are executed by the dispatch method
349
+ * queue.dispatch();
350
+ * }
351
+ * @endcode
277
352
*/
278
353
template <typename F, typename ...Args>
279
354
int call_every (int ms, F f, Args ...args);
@@ -293,6 +368,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
293
368
* @param obj Object to call with the member function
294
369
* @param method Member function to execute in the context of the dispatch loop
295
370
* @param args Arguments to pass to the callback
371
+ *
372
+ * @code
373
+ * int main() {
374
+ * // creates a queue with the default size
375
+ * EventQueue queue;
376
+ *
377
+ * // events are simple callbacks
378
+ * queue.call(printf, "called immediately\n");
379
+ * queue.call_in(2000, printf, "called in 2 seconds\n");
380
+ * queue.call_every(1000, printf, "called every 1 seconds\n");
381
+ *
382
+ * // events are executed by the dispatch method
383
+ * queue.dispatch();
384
+ * }
385
+ * @endcode
296
386
*/
297
387
template <typename T, typename R, typename ...Args>
298
388
int call_every (int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -311,7 +401,26 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
311
401
* @return Event that will dispatch on the specific queue
312
402
*
313
403
* @code
314
- * event(...TODO....);
404
+ * #include "mbed.h"
405
+ *
406
+ * void handler(int c) {
407
+ * printf("Param: %d\r\n", c);
408
+ * }
409
+ *
410
+ * EventQueue q;
411
+ *
412
+ * int main()
413
+ * {
414
+ * // Create event with parameter
415
+ * Event<void()> e = q.event(handler, 1);
416
+ * e();
417
+ *
418
+ * // Create event and post parameter later
419
+ * Event<void(int)> e2 = q.event(handler);
420
+ * e2.post(2);
421
+ *
422
+ * q.dispatch();
423
+ * }
315
424
* @endcode
316
425
*/
317
426
template <typename R, typename ...BoundArgs, typename ...Args>
@@ -332,6 +441,33 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
332
441
* @param method Member function to execute in the context of the dispatch loop
333
442
* @param context_args TODO
334
443
* @return Event that will dispatch on the specific queue
444
+ *
445
+ * @code
446
+ * #include "mbed.h"
447
+ *
448
+ * class Test {
449
+ * int _id;
450
+ *
451
+ * public:
452
+ * Test(int id) : _id(id) { }
453
+ *
454
+ * void handler(int c) {
455
+ * printf("ID: %d Param: %d\r\n", _id, c);
456
+ * }
457
+ * };
458
+ *
459
+ * EventQueue q;
460
+ *
461
+ * int main()
462
+ * {
463
+ * Test handler_cb(5);
464
+ *
465
+ * // Create event on the eventqueue with a method callback
466
+ * Event<void(int)> e = q.event(&handler_cb, &Test::handler);
467
+ * e.post(1);
468
+ * q.dispatch();
469
+ * }
470
+ * @endcode
335
471
*/
336
472
template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args>
337
473
Event<void (Args...)> event (T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args);
@@ -369,6 +505,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
369
505
* enough memory to allocate the event.
370
506
* Returned id will remain valid until event has finished
371
507
* executing.
508
+ *
509
+ * @code
510
+ * #include "mbed.h"
511
+ *
512
+ * EventQueue q;
513
+ *
514
+ * int main()
515
+ * {
516
+ * Callback<void(int)> cb(handler);
517
+ * // Create event on the eventqueue with a separate callback object
518
+ * Event<void(int)> e = q.event(cb);
519
+ * e.post(1);
520
+ * q.dispatch();
521
+ * }
522
+ * @endcode
372
523
*/
373
524
template <typename F>
374
525
int call (F f) {
0 commit comments