[Interest] Heavily Commented Example: Simple Single Frontend with Two BackendsLow,
d3faultdotxbe at gmail.com
Sat Oct 27 02:32:40 CEST 2012
Just about threw up when I woke up and realized what I had done (I
dream in code). Isn't the address of a stack object, when accessed
from another thread, not guaranteed to even be valid? Doesn't each
context/thread have it's own stack? I don't know, but it just seems
gross. The only justification I had for allocating it on the stack was
that it would be a stronger guarantee that when run() went out of
scope, the object would be deleted (like a QMutexLocker). The only
case I can think of where it would do that without continuing after
exec() is if terminate() is called. If you're terminating, you have
bigger problems than a leaked object on the heap.
So I changed it to now allocate the object on the heap instead. I am
not even sure it should have worked to begin with. Maybe I was just
getting lucky because I'm testing on a single core x86? No idea tbh,
but this change eases a pain in my stomach.
http://www2.zshare.ma/80wny0lnxfdt [also attached]
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 18727 bytes
Desc: not available
More information about the Interest