4
votes
Vote UpVote

Busy-Wait Initialization

The Delphi Geek – In response to my recent article on various kinds of initialization, GJ proposed another algorithm, which I will call here busy-wait initialization. This is the first time I’ve encountered this approach and I have no idea whether it is wide-known and has an “official” name. The algorithm itself is very simple: class function BusyWait<T>.Initialize(var storage: T; factory: TFactory): T; begin if storage <> nil then begin if InterlockedCompareExchangePointer( PPointer(@storage)^, PPointer(@factory)^, nil) = nil then storage := factory(); while ...
Favorite? Off-Topic? gabr @ 2011-12-04 17:58

Statistics

Visits: 767
Votes: 4
Favorites: 0
Off-Topic: 1

Visits by Source

User Actions

Users who voted for this posting

François
knight_killer
Philnext
vcldeveloper
Subscribe:
Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News

Sponsor

 
Please login or register to use this functionality.
(click on this box to dismiss)