문제

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.

도움이 되었습니까?

해결책

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.

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top