On Fri, 18 Oct 2024, Martin Frb via fpc-pascal wrote:
On 18/10/2024 10:41, Karoly Balogh via fpc-pascal wrote:
For once, I'd be really glad if a bunch of the containers would be
Thread-Safe by default, like TList and things, and they aren't, because
they're based on almost 3 decade old Delphi concepts, when multithreading
wasn't as big of a deal as these days. No amount of "lets add GC" would
fix this. (And I know we have thread-safe alternatives, but they aren't
used everywhere and consistently. So when using a bunch of libraries, you
still end up managing thread-safety by hand...)
And, I am glad they are **not** used everywhere by default.
I want to control when and where my threads interact with other threads. And
anywhere else, they are to access only data that is not shared (including any
list that they use, outside the zones I designated for sharing).
So no list (of my own, or any 3rd party code), in no thread of mine should
manage that on its own. I will do so, as I see fit for the context of my app.
(That doesn't mean that I object to the existence of such list as
alternative, that can be used wherever it is seen fit)
Of course, that means no 3rd party code must introduce global vars. If it
does => bad.
I agree with Martin. Threading should always be optional.
But to have a set of 'primitive' classes (lists etc.) that handle threading
in SyncObjs would be good, though.
So people do not have to re-implement them themselves.
Michael.
_______________________________________________
fpc-pascal maillist - fpc-pascal@lists.freepascal.org
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal