Skip to content

Commit c802f77

Browse files
committed
Add inline doxy examples for eventqueue method calls
1 parent 04fe577 commit c802f77

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
@@ -197,6 +197,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
197197
* enough memory to allocate the event.
198198
* Returned id will remain valid until event has finished
199199
* 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
200215
*/
201216
template <typename F, typename ...Args>
202217
int call(F f, Args ...args);
@@ -217,6 +232,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
217232
* enough memory to allocate the event.
218233
* Returned id will remain valid until event has finished
219234
* 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
220250
*/
221251
template <typename T, typename R, typename ...Args>
222252
int call(T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -234,6 +264,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
234264
* @return A unique id that represents the posted event and can
235265
* be passed to cancel, or an id of 0 if there is not
236266
* 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
237282
*/
238283
template <typename F, typename ...Args>
239284
int call_in(int ms, Args ...args);
@@ -253,6 +298,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
253298
* @return A unique id that represents the posted event and can
254299
* be passed to cancel, or an id of 0 if there is not
255300
* 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
256316
*/
257317
template <typename T, typename R, typename ...Args>
258318
int call_in(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -274,6 +334,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
274334
* @return A unique id that represents the posted event and can
275335
* be passed to cancel, or an id of 0 if there is not
276336
* 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
277352
*/
278353
template <typename F, typename ...Args>
279354
int call_every(int ms, F f, Args ...args);
@@ -293,6 +368,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
293368
* @param obj Object to call with the member function
294369
* @param method Member function to execute in the context of the dispatch loop
295370
* @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
296386
*/
297387
template <typename T, typename R, typename ...Args>
298388
int call_every(int ms, T *obj, R (T::*method)(Args ...args), Args ...args);
@@ -311,7 +401,26 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
311401
* @return Event that will dispatch on the specific queue
312402
*
313403
* @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+
* }
315424
* @endcode
316425
*/
317426
template <typename R, typename ...BoundArgs, typename ...Args>
@@ -332,6 +441,33 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
332441
* @param method Member function to execute in the context of the dispatch loop
333442
* @param context_args TODO
334443
* @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
335471
*/
336472
template <typename T, typename R, typename ...BoundArgs, typename ...ContextArgs, typename ...Args>
337473
Event<void(Args...)> event(T *obj, R (T::*method)(BoundArgs..., Args...), ContextArgs ...context_args);
@@ -369,6 +505,21 @@ class EventQueue : private mbed::NonCopyable<EventQueue> {
369505
* enough memory to allocate the event.
370506
* Returned id will remain valid until event has finished
371507
* 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
372523
*/
373524
template <typename F>
374525
int call(F f) {

0 commit comments

Comments
 (0)