Replies: 9 comments
-
|
But your example does not use that mutex at all as poll_can_browse does not access queriers not the daemon of the state |
Beta Was this translation helpful? Give feedback.
-
|
And otherwise where we use the mutex we clone the daemon before moving it into the async task |
Beta Was this translation helpful? Give feedback.
-
I'm just giving an example, other commands are use |
Beta Was this translation helpful? Give feedback.
-
|
But not in async code at all so replacement does not make any sense to me. |
Beta Was this translation helpful? Give feedback.
-
the std mutex lock os threads 。But tokio::sync::Mutex not ? |
Beta Was this translation helpful? Give feedback.
-
|
You mean std::sync::Mutex blocks threads? But there is no issue with that as those locks are pretty short in our case, those are just released again shortly after moving on to async code. |
Beta Was this translation helpful? Give feedback.
-
You can search the difference between tokio:: sync:: Mutex and std:: sync:: Mutex。(tauri async is use tokio runtime by default) When concurrency is high, you will encounter |
Beta Was this translation helpful? Give feedback.
-
|
In fact, both can be used, just in terms of performance. That's more suitable |
Beta Was this translation helpful? Give feedback.
-
I've in fact searched for the difference, and from my point of view, it would be wrong to switch to tokio::sync::Mutex, as we never use a mutex in a async context, nor do we create many threads. Therefore the argument with encountering performance impacts in high concurrency situations is just wrong. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
What happened?
the project ManagedState struct and SharedServiceDaemon : use std::sync::Mutex;
but when tauri command async use tauri::async_runtime::spawn; like this
the standard library Mutex lock in the tokio runtime result in poor performance? use tokio::sync::Mutex; Replace it?
Steps to Reproduce
about use std::sync::Mutex
Operating System
Windows
Install Method
None
Relevant log output
Beta Was this translation helpful? Give feedback.
All reactions