Skip to content

Commit 693f0bd

Browse files
kegilbertadbridge
authored andcommitted
Add inline doxy examples for eventqueue method calls
1 parent 5422eb5 commit 693f0bd

File tree

1 file changed

+152
-1
lines changed

1 file changed

+152
-1
lines changed

events/EventQueue.h

Lines changed: 152 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
200200
* enough memory to allocate the event.
201201
* Returned id will remain valid until event has finished
202202
* 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
203218
*/
204219
template <typename F, typename ...Args>
205220
int call(F f, Args ...args);
@@ -220,6 +235,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
220235
* enough memory to allocate the event.
221236
* Returned id will remain valid until event has finished
222237
* 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
223253
*/
224254
template <typename T, typename R, typename ...Args>
225255
int call(T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -237,6 +267,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
237267
* @return A unique id that represents the posted event and can
238268
* be passed to cancel, or an id of 0 if there is not
239269
* 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
240285
*/
241286
template <typename F, typename ...Args>
242287
int call_in(int ms, Args ...args);
@@ -256,6 +301,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
256301
* @return A unique id that represents the posted event and can
257302
* be passed to cancel, or an id of 0 if there is not
258303
* 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
259319
*/
260320
template <typename T, typename R, typename ...Args>
261321
int call_in(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -277,6 +337,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
277337
* @return A unique id that represents the posted event and can
278338
* be passed to cancel, or an id of 0 if there is not
279339
* 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
280355
*/
281356
template <typename F, typename ...Args>
282357
int call_every(int ms, F f, Args ...args);
@@ -296,6 +371,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
296371
* @param obj Object to call with the member function
297372
* @param method Member function to execute in the context of the dispatch loop
298373
* @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
299389
*/
300390
template <typename T, typename R, typename ...Args>
301391
int call_every(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -314,7 +404,26 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
314404
* @return Event that will dispatch on the specific queue
315405
*
316406
* @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+
* }
318427
* @endcode
319428
*/
320429
template <typename R, typename ...BoundArgs, typename ...Args>
@@ -335,6 +444,33 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
335444
* @param method Member function to execute in the context of the dispatch loop
336445
* @param context_args TODO
337446
* @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
338474
*/
339475
template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args>
340476
Event<void(Args...)> event(T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args);
@@ -372,6 +508,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
372508
* enough memory to allocate the event.
373509
* Returned id will remain valid until event has finished
374510
* 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
375526
*/
376527
template <typename F>
377528
int call(F f)

0 commit comments

Comments
 (0)