Forum > General

TThread in an array - freezes on closing

<< < (2/2)

Slawek:

--- Quote from: alpine on February 09, 2023, 04:07:13 pm ---@Slawek
You are making the same mistake I wrote about:
https://forum.lazarus.freepascal.org/index.php/topic,62182.msg470478.html#msg470478

--- End quote ---
Yes. I already know it's a mistake. I have read your advice, but I need to calmly analyze it and read more about it. I wanted to reply to you when I can test it. I have other urgent matters at the moment.
I've noticed that there's a lot of bad threading advice on the internet. This makes it difficult to understand the topic. I don't always know which advice is bad and which is good.

Slawek:

--- Quote from: Warfley on February 09, 2023, 03:54:53 pm ---For this purpose there exist a special synchronization datastructure called a barrier: https://en.m.wikipedia.org/wiki/Barrier_(computer_science)

--- End quote ---
Thank you. I'll be interested in it. I might find it useful  :)

Thaddy:

--- Quote from: Warfley on February 09, 2023, 03:54:53 pm ---For this purpose there exist a special synchronization datastructure called a barrier:

--- End quote ---

And in Freepascal that is already implemented in the system unit. readwrite, readdependency, read and write barriers are supported from 3.2.2 or higher.
https://www.freepascal.org/docs-html/rtl/system/readwritebarrier.html

Pity Warfley forgot to mention that.
It is also very low level and not suited to beginners.

Warfley:
You don't need to use the complicated fpc barriers both pthread and winapi barriers are very easy to use. A few years ago I've wrote a wrapper for both of those: https://github.com/Warfley/FPCBarrier/blob/master/barrier.pas
If you focus on one system it is very easy, but even with the ifdefs it is just 80 lines of code

Navigation

[0] Message Index

[*] Previous page

Go to full version