![]() |
Readers-writer lock - Part 4: Improving TLightweightMREW
While the TLightweightMREW*is quite handy, it is not perfect. There's a weird assymmetry in it. On all operating systems that Delphi can compile for, read*locks are reentrant (recursive) while write*locks are not. In other words, if a thread already owns a read lock, it can call BeginRead*again and it will succeed. Write locks are different. If a thread already owns a write lock and calls BeginWrite*again, it will either deadlock (on Windows) or raise an exception (on other supported platforms). This is, however, relatively simple to fix. I have implemented a simple wrapper for the TLightweightMREW lock in TLightweightMREWEx. This new record uses internal TLightweightMREW*to provide locking and adds some simple logic to implement write lock reentrancy. The implementation and accompanying test program rwReentrantWriter*can be found at* ![]() ![]() ![]() ![]() |
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:47 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz