[fpc-devel] threadvar vs docs
Michael Van Canneyt
michael at freepascal.org
Fri Oct 18 14:30:26 CEST 2024
On Fri, 18 Oct 2024, Nikolay Nikolov via fpc-devel wrote:
>
> On 10/18/24 12:10 AM, Martin Frb via fpc-devel wrote:
>> https://wiki.freepascal.org/Threadvar
>>> If threads are used then a copy is made for each thread (including
>>> the main thread). Note that the copy is made with the original value
>>> of the variable, not with the value of the variable at the time the
>>> thread is started.
>>
>> But what is that original value? Since
>> threadvar
>> foo: integer = 1;
>>
>> gives
>> Error: Cannot initialize variables declared as threadvar
>
> I think the documentation is wrong. Threadvars are always initialized as
> zero.
Then please explain what do copy_all_unit_threadvars and copy_unit_threadvars do ?
This is called from InitThreadVars when a new thread is started.
Michael.
More information about the fpc-devel
mailing list