Pregunta

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.

¿Fue útil?

Solución

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.

Otros consejos

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

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top