I always use D, but typically it's in the Set/Get methods of a property. But it does depend upon what you really want to do, especially if you need to update multiple values simultaneously.
-----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Behalf Of Brian Sent: Thursday, November 17, 2005 4:58 PM To: [email protected] Subject: Mutil-Thread & TMultiReadExclusiveWriteSynchronizer 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 __________________________________________________ Delphi-Talk mailing list -> [email protected] http://www.elists.org/mailman/listinfo/delphi-talk
