This is the mail archive of the
libstdc++@gcc.gnu.org
mailing list for the libstdc++ project.
Re: [c++0x] <future>
2009/5/21 Jonathan Wakely:
>
> I also realised that there's a potential for deadlock while setting
> the value on the promise. ?If the object being copied/moved into the
> result checks the state of the associated future in the copy/move
> operation it will deadlock, because the lock is held during the
> copy/move. ?That requires the result to be aware of the future that
> will contain the result and such a cycle is probably unlikely, but
> I'll see what I can do to avoid it.
>
> I've also assumed the result is DefaultConstructable, I might need to
> dynamically allocate it to avoid that.
Dynamically allocating the result (and storing it in a
std::unique_ptr) will also avoid the deadlock, since I can use
unique_ptr::swap() to set the result, and do the actual copy/move
outside the scope of the lock.
I'll work on that asap.