In a server, I need to have a fairly complex global data structure
accessible from several "client handling" worker threads (very frequent
READs and occasional WRITEs)
I intend to protect the data structure using a
TMultiReadExclusiveWriteSynchronizer
My question, which is "better" (ie reliability, programming "style", ease
of maintenance and SPEED)
Application I have is very time sensitive - server must respond quickly
----------------------------------------------------------------------------
--------------------------------------
Option A - LOCK separate from class
TMyDataStructure = class
private
...
public
...
end;
var
DataLock : TMultiReadExclusiveWriteSynchronizer;
DataStructure : TMyDataStructure;
----------------------------------------------------------------------------
--------------------------------------
Option B - LOCK as a public member of the class
TMyDataStructure = class
private
...
public
Lock : TMultiReadExclusiveWriteSynchronizer;
...
end;
var
DataStructure : TMyDataStructure;
----------------------------------------------------------------------------
--------------------------------------
Option C - LOCK as a private member of the class (with helper methods)
TMyDataStructure = class
private
...
Lock : TMultiReadExclusiveWriteSynchronizer;
public
procedure LockForRead;
procedure UnLockFromRead;
procedure LockForWrite;
procedure UnLockFromWrite;
...
end;
var
DataStructure : TMyDataStructure;
----------------------------------------------------------------------------
--------------------------------------
Option D - LOCK as a private member of the class
(with NO helper methods - that is, LOCKing performed internally)
TMyDataStructure = class
private
...
Lock : TMultiReadExclusiveWriteSynchronizer;
public
...
end;
var
DataStructure : TMyDataStructure;
__________________________________________________
Delphi-Talk mailing list -> [email protected]
http://www.elists.org/mailman/listinfo/delphi-talk