Proper destruction of task

This commit is contained in:
Amos Bird 2023-08-19 13:56:57 +08:00
parent e7d0edfce6
commit 052281896a
No known key found for this signature in database
GPG Key ID: 80D430DCBECFEDB4

View File

@ -266,7 +266,7 @@ namespace
{ {
for (auto && send_data_task : send_data_tasks) for (auto && send_data_task : send_data_tasks)
{ {
send_data_threads.emplace_back([task = std::move(send_data_task), this]() send_data_threads.emplace_back([task = std::move(send_data_task), this]() mutable
{ {
try try
{ {
@ -276,6 +276,10 @@ namespace
{ {
std::lock_guard lock(send_data_lock); std::lock_guard lock(send_data_lock);
exception_during_send_data = std::current_exception(); exception_during_send_data = std::current_exception();
/// task should be reset inside catch block or else it breaks d'tor
/// invariants such as in ~WriteBuffer.
task = {};
} }
}); });
} }