Skip to content

Do I really need mutexes to do any mutation despite not using threads at all? #689

Answered by ogoffart
hbina asked this question in Q&A
Discussion options

You must be logged in to vote

I'm not sure I understand the question, but our code looks correct, yes.
If you want to share mongodb_url to another thread, it needs to be in a Arc<Mutex<...>>

Does this mean that I need a lock for all the interactions between the UI and the application logic?

Sort of, yes.
The UI is in the main thread, and all your callback and functions are going to be run in that thread.
If your logic is in a Arc<Mutex<..>> you indeed need to lock it.

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@hbina
Comment options

@ogoffart
Comment options

@hbina
Comment options

@ogoffart
Comment options

Answer selected by hbina
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants