Win32 Critical Sections use some spins before wait. You have only 2 readers thread and rare writes. Just use a single Critical section for the whole thing, and I thing you willl get a very good performance/simplicity ratio. You may want to use RAII idiom to prevent exit path leaving the CS acquired.
Multiple readers / single writer lock using WinAPI
-
01-07-2022 - |
سؤال
Is there a commonly used, "best practice" read-write lock WinAPI implementation? I've only found one implementation and don't know if it's reliable.
المحلول
نصائح أخرى
There's no such lock in WinXP API. You can use shared_mutex from boost. Example. Btw, such locks make sense when you have a lot of readers and a few of occasional writers. If it's not you case - just use mutex (critical section).
لا تنتمي إلى StackOverflow