[D-runtime] About a suspension comment in core.thread
Alex Rønne Petersen
xtzgzorex at gmail.com
Fri Jun 22 13:19:05 PDT 2012
Hey,
In core.thread:suspend(), there is this comment:
// NOTE: It's really not ideal to wait for each thread to
// signal individually -- rather, it would be better to
// suspend them all and wait once at the end. However,
// semaphores don't really work this way, and the obvious
// alternative (looping on an atomic suspend count)
// requires either the atomic module (which only works on
// x86) or other specialized functionality. It would
// also be possible to simply loop on sem_wait at the
// end, but I'm not convinced that this would be much
// faster than the current approach.
sem_wait( &suspendCount );
Has this turned out to be a performance problem in practice? These
days, core.atomic works everywhere (LDC and GDC use intrinsics), so
using that should be trivial. But I don't want to bother with this if
no one has had performance problems with this suspension strategy
anyway.
Regards,
Alex
More information about the D-runtime
mailing list