2020-10-10 21:37:36 +02:00
|
|
|
//
|
2024-01-01 01:07:21 +01:00
|
|
|
// Copyright Aliaksei Levin (levlam@telegram.org), Arseny Smirnov (arseny30@gmail.com) 2014-2024
|
2020-10-10 21:37:36 +02:00
|
|
|
//
|
|
|
|
// 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)
|
|
|
|
//
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <atomic>
|
|
|
|
|
|
|
|
namespace td {
|
|
|
|
|
|
|
|
class ExitGuard {
|
|
|
|
public:
|
|
|
|
ExitGuard() = default;
|
|
|
|
ExitGuard(ExitGuard &&) = delete;
|
|
|
|
ExitGuard &operator=(ExitGuard &&) = delete;
|
|
|
|
ExitGuard(const ExitGuard &) = delete;
|
|
|
|
ExitGuard &operator=(const ExitGuard &) = delete;
|
2020-10-11 13:45:22 +02:00
|
|
|
~ExitGuard();
|
2020-10-10 21:37:36 +02:00
|
|
|
|
|
|
|
static bool is_exited() {
|
|
|
|
return is_exited_.load(std::memory_order_relaxed);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
static std::atomic<bool> is_exited_;
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace td
|