Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top