mirror of
https://github.com/Naios/continuable.git
synced 2026-02-13 05:39:49 +08:00
Fix a deadlock
This commit is contained in:
parent
ab12986cd9
commit
8f6a0f7bef
10
test.cpp
10
test.cpp
@ -353,7 +353,8 @@ public:
|
|||||||
void _Shutdown(TerminationMode const mode)
|
void _Shutdown(TerminationMode const mode)
|
||||||
{
|
{
|
||||||
_shutdown = mode;
|
_shutdown = mode;
|
||||||
for (auto& thread : _pool)
|
_condition.notify_all();
|
||||||
|
for (auto&& thread : _pool)
|
||||||
if (thread.joinable())
|
if (thread.joinable())
|
||||||
thread.join();
|
thread.join();
|
||||||
}
|
}
|
||||||
@ -679,7 +680,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
|
|
||||||
DispatcherPool countPool(1);
|
DispatcherPool countPool(1);
|
||||||
|
|
||||||
DispatcherPool pool(3);
|
DispatcherPool pool;
|
||||||
|
|
||||||
auto const seed = std::chrono::steady_clock::now().time_since_epoch().count();
|
auto const seed = std::chrono::steady_clock::now().time_since_epoch().count();
|
||||||
|
|
||||||
@ -700,7 +701,7 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
|
|
||||||
pool.Dispatch([&countPool, &container, i, run, wait]
|
pool.Dispatch([&countPool, &container, i, run, wait]
|
||||||
{
|
{
|
||||||
std::this_thread::sleep_for(std::chrono::milliseconds(wait));
|
// std::this_thread::sleep_for(std::chrono::milliseconds(wait));
|
||||||
std::string str = "Pass " + std::to_string(run) + " dispatching " + std::to_string(i) + " (" + std::to_string(wait) + "ms delay)" + "\n";
|
std::string str = "Pass " + std::to_string(run) + " dispatching " + std::to_string(i) + " (" + std::to_string(wait) + "ms delay)" + "\n";
|
||||||
std::cout << str;
|
std::cout << str;
|
||||||
|
|
||||||
@ -717,6 +718,9 @@ int main(int /*argc*/, char** /*argv*/)
|
|||||||
std::cout << "Awaiting termination...\n";
|
std::cout << "Awaiting termination...\n";
|
||||||
|
|
||||||
// std::this_thread::sleep_for(std::chrono::seconds(5));
|
// std::this_thread::sleep_for(std::chrono::seconds(5));
|
||||||
|
|
||||||
|
std::this_thread::sleep_for(std::chrono::seconds(10));
|
||||||
|
|
||||||
pool.Await();
|
pool.Await();
|
||||||
countPool.Await();
|
countPool.Await();
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user