* Valdis Kletnieks: > And to be honest - the "best" way of fixing this is *really* going to depend > on > the relative weight of locking (which can be *very* different if you have 2 > threads on 2 CPUs, or 4096 threads on a 4096-core monster, or are split across > systems possibly in different countries connected by a high or maybe low speed > network), and how much effort goes into the computation, and how much > correctness matters
Right. And in general, it doesn't make sense to reinvent the wheel. The platform probably has got some sort of ivar or future which takes care of the synchronization/blocking. (If it doesn't, you should implement that abstraction first.) Unless the computation is very, very cheap (or requests are truly random), you want other threads to block until the result computed in the initial thread becomes available---without busy waiting. _______________________________________________ Full-Disclosure - We believe in it. Charter: http://lists.grok.org.uk/full-disclosure-charter.html Hosted and sponsored by Secunia - http://secunia.com/
