diff --git a/tests/io_test.cpp b/tests/io_test.cpp index c15ddc2..514efba 100644 --- a/tests/io_test.cpp +++ b/tests/io_test.cpp @@ -39,6 +39,8 @@ int main() { assert(scope_runner.count == -1); auto lock = scope_runner.continue_lock(); assert(!lock); + scope_runner.stop(); + assert(scope_runner.count == -1); scope_runner.count = 0; diff --git a/utility.hpp b/utility.hpp index 94def45..6f733f9 100644 --- a/utility.hpp +++ b/utility.hpp @@ -289,6 +289,8 @@ namespace SimpleWeb { void stop() { long expected = 0; while(!count.compare_exchange_weak(expected, -1)) { + if(expected < 0) + return; expected = 0; spin_loop_pause(); }