WordCount performance

janderson askme at me.com
Sat Mar 29 00:15:46 PDT 2008


Walter Bright wrote:
> Sean Kelly wrote:
>> Another option might be to check the thread count is greater than
>> 1 and only lock if it is.  Tango has a routine called thread_needLock
>> for this purpose, though it goes a bit farther and is true once a
>> thread has been created through program termination.  This avoids
>> problems with the situation where you have multiple threads running
>> and all but one terminate but memory is not yet synchronized.
> 
> You have to be very careful with such schemes because they can run afoul 
> of the notoriously difficult to comprehend "double checked locking" bug.

Perhaps a method of disabling locking would be useful.  Either by simply 
providing a lock free version of the function or by being able to turn 
locking on/off.   Either way the user would be the one who would 
explicitly disable it.

-Joel



More information about the Digitalmars-d mailing list