template statistics
Walter Bright
newshound2 at digitalmars.com
Thu Jun 4 01:38:50 UTC 2020
On 6/3/2020 3:21 PM, Steven Schveighoffer wrote:
> Unless you are suggesting that Phobos completely drop support for interleaving
> printf and writeln calls? If you are, I assure you Walter will not accept that.
I just checked with him, and he assured me he won't.
Also, a plain writeln("hello") must be thread safe just like puts("hello"). The
reason is simply customer demand. I recall the bad old days when multiple
threads would write to stdout, and you'd get:
heworllldo
and everyone would complain. People accept that printfs can be interleaved on
the function call level, but not inside the call. Furthermore, stdout has to
acquire a mutex before writing to it:
acquire stdout mutex
print 'h'
release stdout mutex
acquire stdout mutex
print 'e'
release stdout mutex
acquire stdout mutex
print 'l'
release stdout mutex
turns out to be disastrously slower than:
acquire stdout mutex
print 'hello'
release stdout mutex
More information about the Digitalmars-d
mailing list