pascalfreepascallazarus

Is TFPGMap thread‐safe?


I have a question about TFPGMap from the fgl unit in FreePascal. Is this thread‐safe? Or do I have to use critical sections?

var map:TFPGMap;
begin
map:=TFPGMap.Create();
(...)
CS.Enter;
map.Find('Key');
CS.Leave;

Solution

  • Is TFPGMap thread safe?

    No it is not.

    Such classes never are threadsafe because we're they made that way then all consumers would pay the price even those that don't want to pay the price. You will need to implement your own synchronisation.