Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ (eventqueue): Add cancelLastCall #1252

Merged
merged 1 commit into from
Jan 13, 2023

Conversation

YannLocatelli
Copy link
Member

No description provided.

@codecov
Copy link

codecov bot commented Jan 13, 2023

Codecov Report

Merging #1252 (7df2d93) into develop (6f2fb0d) will decrease coverage by 0.01%.
The diff coverage is 100.00%.

❗ Current head 7df2d93 differs from pull request most recent head f32cafb. Consider uploading reports for the commit f32cafb to get more accurate results

@@             Coverage Diff             @@
##           develop    #1252      +/-   ##
===========================================
- Coverage    96.21%   96.19%   -0.02%     
===========================================
  Files          146      146              
  Lines         3617     3601      -16     
===========================================
- Hits          3480     3464      -16     
  Misses         137      137              
Impacted Files Coverage Δ
drivers/CoreEventQueue/include/CoreEventQueue.h 100.00% <100.00%> (ø)
libs/RobotKit/include/RobotController.h 94.48% <0.00%> (-0.16%) ⬇️
libs/RobotKit/include/StateMachine.h 100.00% <0.00%> (ø)
libs/BehaviorKit/source/BehaviorKit.cpp 100.00% <0.00%> (ø)

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@github-actions
Copy link

github-actions bot commented Jan 13, 2023

File comparision analysis report

🔖 Info

Target Flash Used (base/head) Fash Used Δ Flash Available (base/head) Static RAM (base/head) Static RAM Δ
bootloader 170348 (64%) ø 91796 (35%)
91796 (35%)
30952 (5%) ø
os 434312 (27%) ø 1130360 (72%)
1130360 (72%)
83064 (15%) ø
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

📝 Summary

Click to show summary
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 434312 (20%) ø 83064 (15%) ø
bootloader ✔️ 170348 (8%) ø 30952 (5%) ø
functional_ut_boost_ut ✔️ 394076 (18%) ø 20456 (3%) ø
functional_ut_core_imu ✔️ 377068 (17%) ø 20432 (3%) ø
functional_ut_deep_sleep_core_buffered_serial ✔️ 360236 (17%) ø 20440 (3%) ø
functional_ut_deep_sleep_core_motor ✔️ 364476 (17%) ø 20480 (3%) ø
functional_ut_deep_sleep_core_pwm ✔️ 366612 (17%) ø 20480 (3%) ø
functional_ut_deep_sleep_log_kit ✔️ 352504 (16%) ø 20408 (3%) ø
functional_ut_deep_sleep_mbed_hal ✔️ 354216 (16%) ø 20408 (3%) ø
functional_ut_file_manager ✔️ 374864 (17%) ø 20696 (3%) ø
functional_ut_firmware_kit ✔️ 366540 (17%) ø 20688 (3%) ø
functional_ut_imu_kit ✔️ 382560 (18%) ø 20424 (3%) ø
functional_ut_io_expander ✔️ 359232 (17%) ø 20424 (3%) ø
functional_ut_qdac ✔️ 360400 (17%) ø 20424 (3%) ø
spike_lk_accel_gyro ✔️ 71184 (3%) ø 11808 (2%) ø
spike_lk_audio ✔️ 126924 (6%) ø 14600 (2%) ø
spike_lk_behavior_kit ✔️ 189000 (9%) ø 48080 (9%) ø
spike_lk_ble ✔️ 229600 (10%) ø 28472 (5%) ø
spike_lk_bluetooth ✔️ 82948 (3%) ø 11544 (2%) ø
spike_lk_cg_animations ✔️ 145848 (6%) ø 46528 (8%) ø
spike_lk_color_kit ✔️ 65776 (3%) ø 13744 (2%) ø
spike_lk_command_kit ✔️ 209184 (9%) ø 52032 (9%) ø
spike_lk_config_kit ✔️ 127268 (6%) ø 14312 (2%) ø
spike_lk_coreled ✔️ 76164 (3%) ø 13688 (2%) ø
spike_lk_core_touch_sensor ✔️ 80228 (3%) ø 12256 (2%) ø
spike_lk_event_queue ✔️ 74800 (3%) ø 12072 (2%) ø
spike_lk_file_manager_kit ✔️ 139336 (6%) ø 14440 (2%) ø
spike_lk_file_reception ✔️ 335792 (16%) ø 27792 (5%) ø
spike_lk_flash_memory ✔️ 63880 (3%) ø 11448 (2%) ø
spike_lk_fs ✔️ 175144 (8%) ø 47904 (9%) ø
spike_lk_imu_kit ✔️ 87700 (4%) ø 12176 (2%) ø
spike_lk_lcd ✔️ 162732 (7%) ø 46664 (8%) ø
spike_lk_led_kit ✔️ 103360 (4%) ø 14528 (2%) ø
spike_lk_log_kit ✔️ 63288 (3%) ø 12256 (2%) ø
spike_lk_motion_kit ✔️ 101764 (4%) ø 14288 (2%) ø
spike_lk_motors ✔️ 62864 (2%) ø 11488 (2%) ø
spike_lk_qdac ✔️ 78628 (3%) ø 11816 (2%) ø
spike_lk_reinforcer ✔️ 206416 (9%) ø 49224 (9%) ø
spike_lk_rfid ✔️ 78956 (3%) ø 11504 (2%) ø
spike_lk_sensors_battery ✔️ 78196 (3%) ø 12568 (2%) ø
spike_lk_sensors_light ✔️ 60056 (2%) ø 11440 (2%) ø
spike_lk_sensors_microphone ✔️ 72496 (3%) ø 11504 (2%) ø
spike_lk_sensors_temperature_humidity ✔️ 67048 (3%) ø 11424 (2%) ø
spike_lk_sensors_touch ✔️ 68600 (3%) ø 11432 (2%) ø
spike_lk_serial_number ✔️ 133020 (6%) ø 14304 (2%) ø
spike_lk_ticker_timeout ✔️ 69052 (3%) ø 11632 (2%) ø
spike_lk_update_process_app_base ✔️ 145100 (6%) ø 15584 (2%) ø
spike_lk_update_process_app_update ✔️ 77632 (3%) ø 12352 (2%) ø
spike_lk_watchdog_isr ✔️ 80068 (3%) ø 13272 (2%) ø
spike_lk_wifi ✔️ 116392 (5%) ø 14808 (2%) ø
spike_mbed_blinky ✔️ 58032 (2%) ø 11400 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 63208 (3%) ø 12448 (2%) ø
spike_stl_cxxsupport ✔️ 58456 (2%) ø 11400 (2%) ø

🗺️ Map files diff output

Click to show diff list
spike_lk_event_queue (click to expand)
--- build_artifacts/base_ref-build-enable_log_debug-OFF/spike_lk_event_queue-map.txt	2023-01-13 15:39:32.843799794 +0000
+++ build_artifacts/head_ref-build-enable_log_debug-OFF/spike_lk_event_queue-map.txt	2023-01-13 15:39:32.995798510 +0000
@@ -1,15 +1,15 @@
 | Module                 |         .text |       .data |        .bss |
 |------------------------|---------------|-------------|-------------|
-| [fill]                 |     158(+158) |       8(+8) |     20(+20) |
+| [fill]                 |     126(+126) |       8(+8) |     20(+20) |
 | [lib]/CoreEventQueue.a |       76(+76) |       0(+0) |       0(+0) |
 | [lib]/c.a              | 26028(+26028) | 2472(+2472) |     58(+58) |
 | [lib]/gcc.a            |   7084(+7084) |       0(+0) |       0(+0) |
 | [lib]/mbed-os-static.a | 27362(+27362) |   444(+444) | 8098(+8098) |
 | [lib]/misc             |     188(+188) |       4(+4) |     28(+28) |
 | [lib]/nosys.a          |       32(+32) |       0(+0) |       0(+0) |
 | [lib]/stdc++.a         |   4760(+4760) |       8(+8) |     44(+44) |
-| main.cpp.obj           |   1516(+1516) |       0(+0) |   600(+600) |
+| main.cpp.obj           |   1548(+1548) |       0(+0) |   600(+600) |
 | Subtotals              | 67204(+67204) | 2936(+2936) | 8848(+8848) |
 Total Static RAM memory (data + bss): 11784(+11784) bytes
 Total Flash memory (text + data): 70140(+70140) bytes
 

@github-actions
Copy link

github-actions bot commented Jan 13, 2023

File comparision analysis report

🔖 Info

Target Flash Used (base/head) Fash Used Δ Flash Available (base/head) Static RAM (base/head) Static RAM Δ
bootloader 182804 (69%) ø 79340 (30%)
79340 (30%)
41648 (7%) ø
os 495284 (31%) ø 1069388 (68%)
1069388 (68%)
94280 (17%) ø
Click to show memory sections
| -          |      Hex |     Bytes |  KiB |
|------------|---------:|----------:|-----:|
| Flash      | 0x200000 | 2 097 152 | 2048 |
| SRAM       |  0x80000 |   524 288 |  512 |
| Bootloader |  0x40000 |   262 144 |  256 |
| Header     |   0x1000 |     4 096 |    4 |
| OS         | 0x17E000 | 1 564 672 | 1528 |
| Tail       |   0x1000 |     4 096 |    4 |
| Scratch    |  0x40000 |   262 144 |  256 |

📝 Summary

Click to show summary
  • ✔️ - existing target
  • ✨ - new target
  • ⚰️ - deleted target
  • ✅ - files are the same
  • ❌ - files are different
Target Status .bin .map Total Flash (base/head) Total Flash Δ Static RAM (base/head) Static RAM Δ
LekaOS ✔️ 495284 (23%) ø 94280 (17%) ø
bootloader ✔️ 182804 (8%) ø 41648 (7%) ø
functional_ut_boost_ut ✔️ 409212 (19%) ø 30608 (5%) ø
functional_ut_core_imu ✔️ 389196 (18%) ø 30584 (5%) ø
functional_ut_deep_sleep_core_buffered_serial ✔️ 368140 (17%) ø 30560 (5%) ø
functional_ut_deep_sleep_core_motor ✔️ 376076 (17%) ø 30632 (5%) ø
functional_ut_deep_sleep_core_pwm ✔️ 378292 (18%) ø 30632 (5%) ø
functional_ut_deep_sleep_log_kit ✔️ 365204 (17%) ø 30976 (5%) ø
functional_ut_deep_sleep_mbed_hal ✔️ 366648 (17%) ø 30560 (5%) ø
functional_ut_file_manager ✔️ 386684 (18%) ø 30856 (5%) ø
functional_ut_firmware_kit ✔️ 378068 (18%) ø 30840 (5%) ø
functional_ut_imu_kit ✔️ 391388 (18%) ø 30576 (5%) ø
functional_ut_io_expander ✔️ 370896 (17%) ø 30576 (5%) ø
functional_ut_qdac ✔️ 372064 (17%) ø 30576 (5%) ø
spike_lk_accel_gyro ✔️ 94048 (4%) ø 22568 (4%) ø
spike_lk_audio ✔️ 137044 (6%) ø 25176 (4%) ø
spike_lk_behavior_kit ✔️ 197564 (9%) ø 58656 (11%) ø
spike_lk_ble ✔️ 237916 (11%) ø 39416 (7%) ø
spike_lk_bluetooth ✔️ 92364 (4%) ø 22224 (4%) ø
spike_lk_cg_animations ✔️ 153608 (7%) ø 57224 (10%) ø
spike_lk_color_kit ✔️ 88480 (4%) ø 24376 (4%) ø
spike_lk_command_kit ✔️ 219508 (10%) ø 63120 (12%) ø
spike_lk_config_kit ✔️ 139244 (6%) ø 25136 (4%) ø
spike_lk_coreled ✔️ 88044 (4%) ø 24264 (4%) ø
spike_lk_core_touch_sensor ✔️ 92884 (4%) ø 22832 (4%) ø
spike_lk_event_queue ✔️ 84152 (4%) ø 22904 (4%) ø
spike_lk_file_manager_kit ✔️ 154368 (7%) ø 25520 (4%) ø
spike_lk_file_reception ✔️ 339748 (16%) ø 38448 (7%) ø
spike_lk_flash_memory ✔️ 86776 (4%) ø 22216 (4%) ø
spike_lk_fs ✔️ 174440 (8%) ø 47992 (9%) ø
spike_lk_imu_kit ✔️ 97920 (4%) ø 22896 (4%) ø
spike_lk_lcd ✔️ 172652 (8%) ø 57496 (10%) ø
spike_lk_led_kit ✔️ 115140 (5%) ø 25104 (4%) ø
spike_lk_log_kit ✔️ 84776 (4%) ø 23408 (4%) ø
spike_lk_motion_kit ✔️ 106736 (5%) ø 24840 (4%) ø
spike_lk_motors ✔️ 86336 (4%) ø 22248 (4%) ø
spike_lk_qdac ✔️ 91572 (4%) ø 22776 (4%) ø
spike_lk_reinforcer ✔️ 215044 (10%) ø 59800 (11%) ø
spike_lk_rfid ✔️ 84088 (4%) ø 22184 (4%) ø
spike_lk_sensors_battery ✔️ 87184 (4%) ø 23280 (4%) ø
spike_lk_sensors_light ✔️ 84072 (4%) ø 22216 (4%) ø
spike_lk_sensors_microphone ✔️ 84824 (4%) ø 22216 (4%) ø
spike_lk_sensors_temperature_humidity ✔️ 90400 (4%) ø 22192 (4%) ø
spike_lk_sensors_touch ✔️ 91672 (4%) ø 22456 (4%) ø
spike_lk_serial_number ✔️ 144900 (6%) ø 25256 (4%) ø
spike_lk_ticker_timeout ✔️ 82712 (3%) ø 22232 (4%) ø
spike_lk_update_process_app_base ✔️ 156876 (7%) ø 26288 (5%) ø
spike_lk_update_process_app_update ✔️ 100456 (4%) ø 23240 (4%) ø
spike_lk_watchdog_isr ✔️ 87392 (4%) ø 24120 (4%) ø
spike_lk_wifi ✔️ 130832 (6%) ø 25528 (4%) ø
spike_mbed_blinky ✔️ 57616 (2%) ø 11496 (2%) ø
spike_mbed_watchdog_ticker_vs_thread ✔️ 84176 (4%) ø 23080 (4%) ø
spike_stl_cxxsupport ✔️ 83488 (3%) ø 22304 (4%) ø

🗺️ Map files diff output

Click to show diff list

No differenes where found in map files.

Copy link
Member

@ladislas ladislas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but after reviewing mbed's documentation, I'm afraid that with the current implementation we might introduce bugs

}

void cancelLastCall() { _event_queue.cancel(_event_id); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would just use cancel

Suggested change
void cancelLastCall() { _event_queue.cancel(_event_id); }
void cancel() { _event_queue.cancel(_event_id); }

in the future we could have call return the id to be able to cancel(id) and share an event queue between different callbacks

what happens if we call call_every multiple times? will the queue call all the callback at the desired interval?

if so, then we should first cancel before using _event_queue.call or _event_queue.call_every

_event_id can be an optional to handle the case where cancel is called before call_every has been called.

@@ -18,19 +18,23 @@ class CoreEventQueue : public interface::EventQueue

void dispatch_forever() final;

void call(auto f, auto... params) { _event_queue.call(f, params...); }
void call(auto f, auto... params) { _event_id = _event_queue.call(f, params...); }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here, the _event_id is not really needed and could even introduce bugs.

_event_queue.call will dispatch the event as soon as it's called .

per mbed documentation, when the event is dispatched, the id is not valid anymore and

It is not safe to call cancel after an event has already been dispatched.
id must be valid i.e. event must have not finished executing.

https://os.mbed.com/docs/mbed-os/v6.15/mbed-os-api-doxy/classevents_1_1_event_queue.html#a9ccb4f1222149f37161430fa2f1974e4

so calling call and then cancel might break the program.

cancel is only really needed for call_every or call_in

@YannLocatelli YannLocatelli force-pushed the yann/feature/coreeventqueue/add-cancel-last-call branch from 7df2d93 to 4c255da Compare January 13, 2023 15:20
@YannLocatelli YannLocatelli force-pushed the yann/feature/coreeventqueue/add-cancel-last-call branch from 4c255da to f32cafb Compare January 13, 2023 15:21
Copy link
Member

@ladislas ladislas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@ladislas ladislas merged commit 7ef4646 into develop Jan 13, 2023
@ladislas ladislas deleted the yann/feature/coreeventqueue/add-cancel-last-call branch January 13, 2023 15:29
@sonarcloud
Copy link

sonarcloud bot commented Jan 13, 2023

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

100.0% 100.0% Coverage
0.0% 0.0% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
01 - type: task Something to do
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants