Example for a global variable in a shared library.#183
Example for a global variable in a shared library.#183funny0facer wants to merge 7 commits intozesterer:masterfrom
Conversation
There was a problem hiding this comment.
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.
examples/global-variable.rs
Outdated
| use library::*; | ||
|
|
||
| fn main() { | ||
| // Imagine having separate idependant processes connecting to the same shared library to get access to hardware ressources. |
There was a problem hiding this comment.
There are some typos and grammatical issues here, and in other comments.
There was a problem hiding this comment.
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.
|
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 |
|
I added also an example for spin::Once. |
4832908 to
ed79ebd
Compare
Referring to #90, I hope this example is considered useful.