Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.

Commit df04ea6

Browse files
committed
Added const attributes to call functions on Event
Although the call operations modify the underlying event queue, the Event class itself is const over these functions. This is important when a part of a larger Callback-type class that marks these functions as const.
1 parent 0bca4da commit df04ea6

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

Event.h

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ class Event<void()> {
179179
* be passed to EventQueue::cancel, or an id of 0 if
180180
* there is not enough memory to allocate the event.
181181
*/
182-
int post() {
182+
int post() const {
183183
if (!_event) {
184184
return 0;
185185
}
@@ -192,7 +192,7 @@ class Event<void()> {
192192
*
193193
* @param a0..a4 Arguments to pass to the event
194194
*/
195-
void call() {
195+
void call() const {
196196
int id = post();
197197
MBED_ASSERT(id);
198198
}
@@ -201,7 +201,7 @@ class Event<void()> {
201201
*
202202
* @param a0..a4 Arguments to pass to the event
203203
*/
204-
void operator()() {
204+
void operator()() const {
205205
return call();
206206
}
207207

@@ -225,7 +225,7 @@ class Event<void()> {
225225
* function does not garuntee that the event will not execute after it
226226
* returns, as the event may have already begun executing.
227227
*/
228-
void cancel() {
228+
void cancel() const {
229229
if (_event) {
230230
equeue_cancel(_event->equeue, _event->id);
231231
}
@@ -398,7 +398,7 @@ class Event<void(A0)> {
398398
* be passed to EventQueue::cancel, or an id of 0 if
399399
* there is not enough memory to allocate the event.
400400
*/
401-
int post(A0 a0) {
401+
int post(A0 a0) const {
402402
if (!_event) {
403403
return 0;
404404
}
@@ -411,7 +411,7 @@ class Event<void(A0)> {
411411
*
412412
* @param a0..a4 Arguments to pass to the event
413413
*/
414-
void call(A0 a0) {
414+
void call(A0 a0) const {
415415
int id = post(a0);
416416
MBED_ASSERT(id);
417417
}
@@ -420,7 +420,7 @@ class Event<void(A0)> {
420420
*
421421
* @param a0..a4 Arguments to pass to the event
422422
*/
423-
void operator()(A0 a0) {
423+
void operator()(A0 a0) const {
424424
return call(a0);
425425
}
426426

@@ -444,7 +444,7 @@ class Event<void(A0)> {
444444
* function does not garuntee that the event will not execute after it
445445
* returns, as the event may have already begun executing.
446446
*/
447-
void cancel() {
447+
void cancel() const {
448448
if (_event) {
449449
equeue_cancel(_event->equeue, _event->id);
450450
}
@@ -617,7 +617,7 @@ class Event<void(A0, A1)> {
617617
* be passed to EventQueue::cancel, or an id of 0 if
618618
* there is not enough memory to allocate the event.
619619
*/
620-
int post(A0 a0, A1 a1) {
620+
int post(A0 a0, A1 a1) const {
621621
if (!_event) {
622622
return 0;
623623
}
@@ -630,7 +630,7 @@ class Event<void(A0, A1)> {
630630
*
631631
* @param a0..a4 Arguments to pass to the event
632632
*/
633-
void call(A0 a0, A1 a1) {
633+
void call(A0 a0, A1 a1) const {
634634
int id = post(a0, a1);
635635
MBED_ASSERT(id);
636636
}
@@ -639,7 +639,7 @@ class Event<void(A0, A1)> {
639639
*
640640
* @param a0..a4 Arguments to pass to the event
641641
*/
642-
void operator()(A0 a0, A1 a1) {
642+
void operator()(A0 a0, A1 a1) const {
643643
return call(a0, a1);
644644
}
645645

@@ -663,7 +663,7 @@ class Event<void(A0, A1)> {
663663
* function does not garuntee that the event will not execute after it
664664
* returns, as the event may have already begun executing.
665665
*/
666-
void cancel() {
666+
void cancel() const {
667667
if (_event) {
668668
equeue_cancel(_event->equeue, _event->id);
669669
}
@@ -836,7 +836,7 @@ class Event<void(A0, A1, A2)> {
836836
* be passed to EventQueue::cancel, or an id of 0 if
837837
* there is not enough memory to allocate the event.
838838
*/
839-
int post(A0 a0, A1 a1, A2 a2) {
839+
int post(A0 a0, A1 a1, A2 a2) const {
840840
if (!_event) {
841841
return 0;
842842
}
@@ -849,7 +849,7 @@ class Event<void(A0, A1, A2)> {
849849
*
850850
* @param a0..a4 Arguments to pass to the event
851851
*/
852-
void call(A0 a0, A1 a1, A2 a2) {
852+
void call(A0 a0, A1 a1, A2 a2) const {
853853
int id = post(a0, a1, a2);
854854
MBED_ASSERT(id);
855855
}
@@ -858,7 +858,7 @@ class Event<void(A0, A1, A2)> {
858858
*
859859
* @param a0..a4 Arguments to pass to the event
860860
*/
861-
void operator()(A0 a0, A1 a1, A2 a2) {
861+
void operator()(A0 a0, A1 a1, A2 a2) const {
862862
return call(a0, a1, a2);
863863
}
864864

@@ -882,7 +882,7 @@ class Event<void(A0, A1, A2)> {
882882
* function does not garuntee that the event will not execute after it
883883
* returns, as the event may have already begun executing.
884884
*/
885-
void cancel() {
885+
void cancel() const {
886886
if (_event) {
887887
equeue_cancel(_event->equeue, _event->id);
888888
}
@@ -1055,7 +1055,7 @@ class Event<void(A0, A1, A2, A3)> {
10551055
* be passed to EventQueue::cancel, or an id of 0 if
10561056
* there is not enough memory to allocate the event.
10571057
*/
1058-
int post(A0 a0, A1 a1, A2 a2, A3 a3) {
1058+
int post(A0 a0, A1 a1, A2 a2, A3 a3) const {
10591059
if (!_event) {
10601060
return 0;
10611061
}
@@ -1068,7 +1068,7 @@ class Event<void(A0, A1, A2, A3)> {
10681068
*
10691069
* @param a0..a4 Arguments to pass to the event
10701070
*/
1071-
void call(A0 a0, A1 a1, A2 a2, A3 a3) {
1071+
void call(A0 a0, A1 a1, A2 a2, A3 a3) const {
10721072
int id = post(a0, a1, a2, a3);
10731073
MBED_ASSERT(id);
10741074
}
@@ -1077,7 +1077,7 @@ class Event<void(A0, A1, A2, A3)> {
10771077
*
10781078
* @param a0..a4 Arguments to pass to the event
10791079
*/
1080-
void operator()(A0 a0, A1 a1, A2 a2, A3 a3) {
1080+
void operator()(A0 a0, A1 a1, A2 a2, A3 a3) const {
10811081
return call(a0, a1, a2, a3);
10821082
}
10831083

@@ -1101,7 +1101,7 @@ class Event<void(A0, A1, A2, A3)> {
11011101
* function does not garuntee that the event will not execute after it
11021102
* returns, as the event may have already begun executing.
11031103
*/
1104-
void cancel() {
1104+
void cancel() const {
11051105
if (_event) {
11061106
equeue_cancel(_event->equeue, _event->id);
11071107
}
@@ -1274,7 +1274,7 @@ class Event<void(A0, A1, A2, A3, A4)> {
12741274
* be passed to EventQueue::cancel, or an id of 0 if
12751275
* there is not enough memory to allocate the event.
12761276
*/
1277-
int post(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
1277+
int post(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
12781278
if (!_event) {
12791279
return 0;
12801280
}
@@ -1287,7 +1287,7 @@ class Event<void(A0, A1, A2, A3, A4)> {
12871287
*
12881288
* @param a0..a4 Arguments to pass to the event
12891289
*/
1290-
void call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
1290+
void call(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
12911291
int id = post(a0, a1, a2, a3, a4);
12921292
MBED_ASSERT(id);
12931293
}
@@ -1296,7 +1296,7 @@ class Event<void(A0, A1, A2, A3, A4)> {
12961296
*
12971297
* @param a0..a4 Arguments to pass to the event
12981298
*/
1299-
void operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) {
1299+
void operator()(A0 a0, A1 a1, A2 a2, A3 a3, A4 a4) const {
13001300
return call(a0, a1, a2, a3, a4);
13011301
}
13021302

@@ -1320,7 +1320,7 @@ class Event<void(A0, A1, A2, A3, A4)> {
13201320
* function does not garuntee that the event will not execute after it
13211321
* returns, as the event may have already begun executing.
13221322
*/
1323-
void cancel() {
1323+
void cancel() const {
13241324
if (_event) {
13251325
equeue_cancel(_event->equeue, _event->id);
13261326
}

0 commit comments

Comments
 (0)