The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 4,262 other subscribers

TInterlocked.Exchange for interfaces?

Posted by jpluimers on 2019/05/29

Via [WayBack] TInterlocked.Exchange for interfaces? Since there is no System.SyncObjs.TInterlocked.Exchange overload for interfaces (and the Exchange versio… – Stefan Glienke – Google+

It has made it to this piece in [Archive.issglienke / Spring4D / source / Source / Reactive / Spring.Reactive.pas — Bitbucket:

class function TInterlockedHelper.Exchange<T>(var Target: T;
  const Value: T): T;
begin
  Result := Default(T);
  PPointer(@Result)^ := Exchange(PPointer(@Target)^, PPointer(@Value)^);
  if Assigned(Value) then
    Value._AddRef;
end;

It is similar to the TInterlocked.Exchange methods.

–jeroen

 

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.