Re: [Phix] Question About Assignment

new topic     » goto parent     » topic index » view thread      » older message » newer message

Thread safety. If multiple threads are calling (eg) [s]printf(), and that was using a common shared "" constant, they c/would stomp all over each other's reference counts, so using repeat(' ',0) instead of "" creates a new private thread-specific (and in fact call-specific) string, obviously with a private reference count that no other thread can possibly access.

If you have a (hidden) reference count of 2, and (without either locking or privacy) one thread increments it at the exact same time as another decrements it, you will end up with either 1 or 3 instead of the desired 2.

Naturally the reference count on a constant should never drop below 1, and catastrophy ensues if it ever does, but it is incremented to trigger either copy-on-write processing or a p2js violation under "with js".

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu