Wednesday, April 08, 2026

OmniThreadLibrary 3.08

Delphi 13.1 has exposed a long-present 64-compatibility bug in OmniThreadLibrary which is fixed in this release. Hopefully this was the last 64-compatibility bug in OTL :)

In other news, this release adds a TLightweightMREWEx extension to TLightweightMREW (Delphi 11+ only). Enhanced version supports nested BeginWrite/EndWrite calls. Read more in article Readers-writer lock - Part 4: Improving TLightweightMREW.

There were significant improvements to Locked<T>. On Delphi 11+ it uses TLightweightMREWEx internally (instead of a critical section). New methods (Delphi 11+ only) were added to support locking with read/write semantics: BeginRead, TryBeginRead, EndRead, BeginWrite, TryBeginWrite, EndWrite. On Delphi 11+,  Acquire/Release methods map to BeginWrite/EndWrite which preserves existing locking semantics. 

Locked<T> also got new access pair Enter/Leave and function IsInitialized. Original access function Acquire is implement as a procedure while new methods BeginRead/BeginWrite work as functions returning original type T. To mirror that, Enter also returns T (while Leave is just an alias for Release).

As a last modifidation, SetThreadName function from OtlCommon.Utils also calls SetThreadDescription Windows API if it is available. This allows logging code to log thread name even if they only know a thread handle by calling GetThreadDescription Windows API.

Download new version from GitHub!

GetIt will be updated soon.