[fpc-pascal] Support for "class threadvar" sections inside class and record types

Sven Barth pascaldragon at googlemail.com
Sat Jun 23 16:45:48 CEST 2018


Ryan Joseph <ryan at thealchemistguild.com> schrieb am Sa., 23. Juni 2018,
16:04:

>
>
> > On Jun 23, 2018, at 8:55 PM, Sven Barth via fpc-pascal <
> fpc-pascal at lists.freepascal.org> wrote:
> >
> > A threadvar section is started using "class threadvar" and the "class"
> specifier is required. They are accessed like ordinary class variables with
> the difference that they'll hold different values per thread - the same as
> global threadvars after all.
> >
> > This feature is Delphi compatible (and was added, because I noticed that
> Delphi supported it and FPC did not 😅)
>
> That’s an interesting idea I wonder how it could be used. Does it do
> anything to help with shared data between threads or is just a way to get
> quick access to thread safe memory?
>

It's merely a scoped threadvar, so nothing special there. And in case you
don't know about threadvars: the concept of them is that every thread has
its own "instance" of the variable.

See also here: https://www.freepascal.org/docs-html/ref/refse26.html

Regards,
Sven

>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20180623/cb3ac28e/attachment.html>


More information about the fpc-pascal mailing list