[fpc-devel] ref count types / threadsave question
Jonas Maebe
jonas at freepascal.org
Sun Jan 6 15:00:44 CET 2019
On 06/01/19 14:42, Martin Frb wrote:
> Btw about threads seeing different cached versions of data.
> What happens in case of synchronize?
Synchronize uses an RtlEvent. That one uses OS primitives that include
memory barriers, so the data will be properly synchronised across cores.
> If so then how to I ever get a managed variable safely into a thread?
> (Once the thread was started).
It behaves the same as any other data.
In general: always use an RTLEvent, mutex, critical section or similar
to access shared data. Those will ensure that the necessary memory
barriers get inserted.
Jonas
More information about the fpc-devel
mailing list