You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The destructor of task_system can sometimes hang. So i believe there is a race somewhere. I'm using the following code where "Done" is sometimes not printed.
{
ts::task_system tp;
const size_t ntests = 1000000;
std::atomic<size_t> counter = 0;
std::mutex lock;
std::condition_variable event;
bool done{false};
const auto start = high_resolution_clock::now();
for (size_t i = 0 ; i < ntests ; ++i)
{
tp.schedule([&] {
++counter;
if (counter == ntests)
{
{
std::unique_lock l{lock};
done = true;
}
event.notify_one();
}
});
}
printf("Enqueued all tasks...\n");
{
std::unique_lock l{lock};
event.wait(l, [&]{return done;});
}
const auto stop = high_resolution_clock::now();
const auto delta = duration_cast<milliseconds>(stop-start).count() * 1e-3;
printf("Enqueued all tasks... Done in %f seconds\n", delta);
}
printf("Done\n");
The text was updated successfully, but these errors were encountered:
The destructor of
task_system
can sometimes hang. So i believe there is a race somewhere. I'm using the following code where "Done" is sometimes not printed.The text was updated successfully, but these errors were encountered: