The exception_container is supposed to be a cheaper, but possibly harder to use alternative to std::exception_ptr. Before this commit, the exception was kept behind foreign_ptr<std::unique_ptr<>> so that moving the container is very cheap. However, the original std::exception_ptr supports copying in a thread-safe manner, and it turns out that some of the read coordinator logic intentionally copies the pointer in order to be able to fail two different promises with the same exception. The pointer type is changed to std::shared_ptr. Although it uses atomics for reference counting, this is also probably what std::exception_ptr does, so the performance should not be worse. The exception stored inside the container is immutable, so this allows for a non-throwing implementation of copying. To encourage moves instead of copying, the copy constructor is deleted and instead the `clone()` method should be used if it is really necessary.
5.2 KiB
5.2 KiB