Skip to content

Conversation

@smaeul
Copy link
Contributor

@smaeul smaeul commented Nov 15, 2025

alloc::sync::Arc is unavailable on targets without atomics, such as ESP32-C3, which is riscv32imc. In this case, use Rc instead, and make the user responsible for synchronization.

I'm not sure if it is okay to do the fallback silently, or if you'd prefer to gate this behind a feature. This is the same condition as used by alloc, so this change should only affect targets which previously would fail to build.

@codecov
Copy link

codecov bot commented Nov 16, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.89%. Comparing base (3db1dd3) to head (8f20e9b).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #46      +/-   ##
==========================================
- Coverage   90.90%   90.89%   -0.02%     
==========================================
  Files          55       55              
  Lines        7456     7456              
==========================================
- Hits         6778     6777       -1     
- Misses        678      679       +1     
Files with missing lines Coverage Δ
src/mqtt/common/arc_payload.rs 88.76% <ø> (ø)
src/mqtt/connection/packet_builder.rs 97.75% <ø> (ø)
src/mqtt/packet/v3_1_1/publish.rs 95.74% <ø> (ø)
src/mqtt/packet/v5_0/publish.rs 94.48% <ø> (ø)

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Owner

@redboltz redboltz left a comment

Choose a reason for hiding this comment

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

Thank you for the PR.

I’ve been thinking about whether automatic detection and switching is really the right choice.

#[cfg(target_has_atomic = "ptr")]

Arc uses A as Atomic, but it silently falls back to a non-atomic reference counter. That’s my first concern.
In practice, this is fine because most multi-threaded environments provide atomic operations for ptr.
In other words, if #[cfg(not(target_has_atomic = "ptr"))] is true, we can assume the environment is single-threaded.

`alloc::sync::Arc` is unavailable on targets without atomics, such as
ESP32-C3, which is riscv32imc. In this case, use `Rc` instead, and make
the user responsible for synchronization.
@smaeul
Copy link
Contributor Author

smaeul commented Nov 17, 2025

In other words, if #[cfg(not(target_has_atomic = "ptr"))] is true, we can assume the environment is single-threaded.

Yes, that is my thought as well.

@redboltz
Copy link
Owner

It seems that github actions' environmental issue is happened. I just cleared cache and re-run the CI process.

@redboltz
Copy link
Owner

Thank you for updating! It looks good to me.

@redboltz redboltz merged commit 609c3a3 into redboltz:main Nov 17, 2025
14 of 18 checks passed
@redboltz
Copy link
Owner

@smaeul Do you have any other (preparing) pull request? If it doesn't, I will release the merged version as the minior updated version. Please let me know.

@smaeul smaeul deleted the up/no-sync branch November 17, 2025 18:45
@smaeul
Copy link
Contributor Author

smaeul commented Nov 17, 2025

@smaeul Do you have any other (preparing) pull request? If it doesn't, I will release the merged version as the minior updated version. Please let me know.

Thanks for the quick review! I have opened issues or PRs for everything I have encountered so far.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants