[fpc-pascal] Thread Safety of String
Ewald
ewald at yellowcouch.org
Wed Jun 4 21:03:29 CEST 2014
On 04 Jun 2014, at 20:42, md at rpzdesign.com wrote:
> For anybody who has followed this thread, there is some disagreement
> over the thread safety of shortstrings. And in this case, a shortstring
> with a clearly defined maximum length.
>
> Some have clearly said string[30] is NOT thread safe.
>
> Rich indicated below he feels they ARE SAFE.
>
Actually, the question is: what do you mean by `thread safe`? So you mean it like: `the variable stays at the same place in memory (but not always, the variable can reside in a register for some time)`, like `accesses to this variable are atomic`, like `this variable will *always* be in memory at the same location (no prolonged life in registers for this bugger)`, or ...?
> Hmmm. Time for DOUBLE jeopardy.
>
> Alex Trebeck says, "I am the son of Ansistring but I don't move around
> much. My pointer is me and I am my pointer."
>
Hmmm, JuniorString must be a cripple philosopher then ;-)
Anyway, I would be interested in the answer, as do you I suppose.
>
> I have to implement the same thread code in C++ a little later, so there
> are no shortstrings in C++, just QStrings. (oops, yeah, I use Qt also)
Time for some nitpicking..Yay! How about:
char YourString[SIZE];
It's kind of a drudgery to handle those though, so I see why you like QStrings better :-)
--
Ewald
More information about the fpc-pascal
mailing list