summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/asio/include/asio/detail/std_event.hpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/asio/include/asio/detail/std_event.hpp')
-rw-r--r--3rdparty/asio/include/asio/detail/std_event.hpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/3rdparty/asio/include/asio/detail/std_event.hpp b/3rdparty/asio/include/asio/detail/std_event.hpp
index e05fcca3316..97a347ed725 100644
--- a/3rdparty/asio/include/asio/detail/std_event.hpp
+++ b/3rdparty/asio/include/asio/detail/std_event.hpp
@@ -2,7 +2,7 @@
// detail/std_event.hpp
// ~~~~~~~~~~~~~~~~~~~~
//
-// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com)
+// Copyright (c) 2003-2024 Christopher M. Kohlhoff (chris at kohlhoff dot com)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
@@ -16,9 +16,6 @@
#endif // defined(_MSC_VER) && (_MSC_VER >= 1200)
#include "asio/detail/config.hpp"
-
-#if defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
-
#include <chrono>
#include <condition_variable>
#include "asio/detail/assert.hpp"
@@ -73,6 +70,18 @@ public:
cond_.notify_one();
}
+ // Unlock the mutex and signal one waiter who may destroy us.
+ template <typename Lock>
+ void unlock_and_signal_one_for_destruction(Lock& lock)
+ {
+ ASIO_ASSERT(lock.locked());
+ state_ |= 1;
+ bool have_waiters = (state_ > 1);
+ if (have_waiters)
+ cond_.notify_one();
+ lock.unlock();
+ }
+
// If there's a waiter, unlock the mutex and signal it.
template <typename Lock>
bool maybe_unlock_and_signal_one(Lock& lock)
@@ -171,6 +180,4 @@ private:
#include "asio/detail/pop_options.hpp"
-#endif // defined(ASIO_HAS_STD_MUTEX_AND_CONDVAR)
-
#endif // ASIO_DETAIL_STD_EVENT_HPP