Il 04/09/2012 13:35, Eric Blake ha scritto: >> > No, it should be only called once, any other thread should not call >> > it again, will document it. About the multiple thread user case, qemu >> > block layer can't support that now, will fix that later. > What a shame. That makes libraries much harder to use. It is much > nicer to design a library where the initialization is idempotent and > thread-safe, to be called from multiple threads. Consider: > > app links against liba and libb; > liba links against libqb > libb links against libqb > > How am I supposed to write liba and libb to guarantee only one single > race-free call to libqblock_init, unless libqblock_init() is idempotent?
I agree, libqblock_init should use pthread_once (or we can add QemuOnce to qemu-thread-*.c). Paolo