[Lazarus] thread safe

Malcom Haak insanemal at gmail.com
Thu Jun 23 00:37:20 CEST 2011


Correct me if I'm wrong, But can't you technically make any code
'thread-safe'  by using Critical Sections before doing work.
In some code I have seen before a critical section was entered before
calling TList.Add
Now provided that you don't need a specific order, does this not then make
it thread safe?

On Wed, Jun 15, 2011 at 1:32 AM, Michael Schnell <mschnell at lumino.de> wrote:

> On 06/14/2011 04:57 PM, Hans-Peter Diettrich wrote:
>
>>
>> How would you expect a thread-safe version to work? A TList doesn't
>> serialize requests, this would have to be added separately.
>>
>>  It does not need to, as  "separate-instance-thread safe" means that each
> thread handles only it's own instance.
>
> "Add" only needs to use stack variables and instance variables. Both are
> dedicated to the thread and thus don't need a protection (OK it if needs to
> allocate memory the heap allocation procedure does need protection
> mechanism, but this is provided by the infrastructure anyway. )
>
> -Michael
>
>
> --
> ______________________________**_________________
> Lazarus mailing list
> Lazarus at lists.lazarus.**freepascal.org<Lazarus at lists.lazarus.freepascal.org>
> http://lists.lazarus.**freepascal.org/mailman/**listinfo/lazarus<http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lazarus-ide.org/pipermail/lazarus/attachments/20110623/d8efe4bb/attachment-0003.html>


More information about the Lazarus mailing list