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