AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Delphi-PRAXiS - Lounge Delphi-News aus aller Welt Readers-writer lock - Part 4: Improving TLightweightMREW
Thema durchsuchen
Ansicht
Themen-Optionen

Readers-writer lock - Part 4: Improving TLightweightMREW

Ein Thema von DP News-Robot · begonnen am 10. Feb 2021
Antwort Antwort
Benutzerbild von DP News-Robot
DP News-Robot

Registriert seit: 4. Jun 2010
14.968 Beiträge
 
#1

Readers-writer lock - Part 4: Improving TLightweightMREW

  Alt 10. Feb 2021, 23:00
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*https://github.com/gabr42/examples/t...-writer%20lock.

Read more »[SIZE=-2]--- Published under the Creative Commons Attribution 3.0 license[/SIZE]


Weiterlesen...
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:19 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz