1
2
Fork
You've already forked spin
0

Example for a global variable in a shared library. #183

Open
funny0facer wants to merge 7 commits from funny0facer/example_for_global_variable into master
pull from: funny0facer/example_for_global_variable
merge into: zesterer:master
zesterer:master
zesterer:fixes
zesterer:fix-ub
zesterer:revert-127-ci
zesterer:spinlock
funny0facer commented 2025年12月24日 12:42:56 +01:00 (Migrated from github.com)
Copy link

Referring to #90, I hope this example is considered useful.

Referring to #90, I hope this example is considered useful.
zesterer (Migrated from github.com) reviewed 2026年01月11日 22:17:22 +01:00
zesterer (Migrated from github.com) left a comment
Copy link

Hmm, I'm not entirely convinced that this is a worthwhile example. spin is specifically not intended for guarding state in a multi-threaded hosted environment: std::sync should be used instead due to concerns like priority inversion. While it's sound to do so, it's almost never a good idea.

Hmm, I'm not entirely convinced that this is a worthwhile example. `spin` is specifically *not* intended for guarding state in a multi-threaded hosted environment: `std::sync` should be used instead due to concerns like [priority inversion](https://en.wikipedia.org/wiki/Priority_inversion). While it's *sound* to do so, it's almost never a *good idea*.
@ -0,0 +1,111 @@
//! This example is focused on the "library" part and not on the "main" function.
zesterer (Migrated from github.com) commented 2026年01月11日 22:14:25 +01:00
Copy link

There are some typos and grammatical issues here, and in other comments.

There are some typos and grammatical issues here, and in other comments.
funny0facer (Migrated from github.com) reviewed 2026年01月11日 22:42:52 +01:00
@ -0,0 +1,111 @@
//! This example is focused on the "library" part and not on the "main" function.
funny0facer (Migrated from github.com) commented 2026年01月11日 22:42:52 +01:00
Copy link

fair point, maybe I tried to oversimplify the example.
I built https://github.com/funny0facer/esp32_interrupts1 and there I use your Mutex to lock a global variable.

fair point, maybe I tried to oversimplify the example. I built https://github.com/funny0facer/esp32_interrupts1 and there I use your Mutex to lock a global variable.
funny0facer commented 2026年01月14日 22:14:49 +01:00 (Migrated from github.com)
Copy link

Maybe you like the new version better.. I focused it now on the use case mentioned on https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html

Maybe you like the new version better.. I focused it now on the use case mentioned on https://doc.rust-lang.org/edition-guide/rust-2024/static-mut-references.html
funny0facer commented 2026年01月24日 10:08:56 +01:00 (Migrated from github.com)
Copy link

I added also an example for spin::Once.
Please let me know if this kind of example is even the thing you were looking for or if you expect something different.

I added also an example for spin::Once. Please let me know if this kind of example is even the thing you were looking for or if you expect something different.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin funny0facer/example_for_global_variable:funny0facer/example_for_global_variable
git switch funny0facer/example_for_global_variable

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch master
git merge --no-ff funny0facer/example_for_global_variable
git switch funny0facer/example_for_global_variable
git rebase master
git switch master
git merge --ff-only funny0facer/example_for_global_variable
git switch funny0facer/example_for_global_variable
git rebase master
git switch master
git merge --no-ff funny0facer/example_for_global_variable
git switch master
git merge --squash funny0facer/example_for_global_variable
git switch master
git merge --ff-only funny0facer/example_for_global_variable
git switch master
git merge funny0facer/example_for_global_variable
git push origin master
Sign in to join this conversation.
No reviewers
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
zesterer/spin!183
Reference in a new issue
zesterer/spin
No description provided.
Delete branch "funny0facer/example_for_global_variable"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?