@@ -10,35 +10,30 @@ void handler(int count);
1010Event<void (int )> event1 (&queue, handler);
1111Event<void (int )> event2 (&queue, handler);
1212
13-
14- void handler (int count)
15- {
13+ void handler (int count) {
1614 unsigned time_ms = equeue_tick ();
1715 printf (" Timestamp = %d Event = %d \n " , time_ms, count);
1816 return ;
1917}
2018
21- void post_events (void )
22- {
19+ void post_events (void ) {
2320 // Events can be posted multiple times and enqueue gracefully until
2421 // the dispatch function is called. Each event will be processed
2522 // subject to any delay and period specified. Each time an event has
2623 // been dispatched it will be re-queued ready for the next dispatch
2724 // period.
28- event1.post (1 ); // Event1 with a value of 1
29- event1.post (2 ); // Event1 with a value of 2
30- event1.post (3 ); // Event1 with a value of 3
25+ event1.post (1 ); // Event1 with a value of 1
26+ event1.post (2 ); // Event1 with a value of 2
27+ event1.post (3 ); // Event1 with a value of 3
3128
3229 // Cancel the last event posted ie Event1 with a value of 3
3330 event1.cancel ();
3431
35- event1.post (4 ); // Event1 with a value of 4
36-
37- event2.post (5 ); // Event2 with a value of 5
32+ event1.post (4 ); // Event1 with a value of 4
3833
34+ event2.post (5 ); // Event2 with a value of 5
3935}
4036
41-
4237// Example demonstrates the following:
4338// 1. Post 5 different events to a queue
4439// 2. Configure the event delay and period for each
@@ -76,18 +71,17 @@ void post_events(void)
7671// Timestamp = 727 Event = 2
7772// Timestamp = 756 Event = 4
7873
79- int main ()
80- {
74+ int main () {
8175 // Example 1 Dispatch posted events for a specified period
8276 Thread event_thread;
8377
8478 // The event can be manually configured for special timing requirements
8579 // specified in milliseconds (using Chrono durations)
86- event1.delay (100ms); // Starting delay - 100 msec
87- event1.period (200ms); // Delay between each event - 200msec
80+ event1.delay (100ms); // Starting delay - 100 msec
81+ event1.period (200ms); // Delay between each event - 200msec
8882
89- event2.delay (400ms); // Starting delay - 400 msec
90- event2.period (non_periodic); // Single non periodic event
83+ event2.delay (400ms); // Starting delay - 400 msec
84+ event2.period (non_periodic); // Single non periodic event
9185
9286 event_thread.start (callback (post_events));
9387
@@ -99,5 +93,4 @@ int main()
9993 queue.dispatch_for (800ms);
10094
10195 event_thread.join ();
102-
10396}
0 commit comments