Closed sierret closed 1 year ago
First, read the multithreading section in the documentation. There are two levels of protection you need.
In general, multithreading is not as straightforward as it may sound. It requires very careful analysis and especially repeated benchmarking and tweaking. Often it is counterproductive. It also differs from one platform to another, because it depends on a particular hardware.
If you are new to multithreaded programming, I suggest you start with a single thread and maybe use the async
interfaces. Once it works correctly, you can convert it to multithreaded version and compare results and efficiency and repeatedly tweak it
I'm sorry. I did read the section and understand the gist of it but can't say I get every single detail. As you say multithreading is indeed pretty complex. Which is exactly why I decided to make post an issue. I suppose what I was basically asking was if the shared/regular mutexes were capable of protecting the static and internal data structures but didn't know how to phrase it. But thank you you answered my question.
I am running multi-threaded where some threads only read and some write. Thus it would be more suitable to use unique_locks and shared_locks with shared_mutexes for efficiency. From what I understand , the locks built in(in particular the Spinlock) don't have the advantages of shared_locks/unique_locks with shared_mutexes for example and lock the entire dataframe for every operation.
Are there any advantages to using your built-in locks or is it better (for me) to switch to to using shared_mutex with unique_lock/shared_lock? Would there also be any compatibility issues?