载入中...
搜索中...
未找到
LifetimeWitness.h
浏览该文件的文档.
1#pragma once
2#include <memory>
3namespace eve {
4class LifetimeOwner;
7 friend class LifetimeOwner;
8 std::weak_ptr<const void> state_;
9
10public:
12 LifetimeWitness() = default;
14 [[nodiscard]] bool isAlive() const noexcept { return !state_.expired(); }
15};
18 std::shared_ptr<const void> state_ = std::make_shared<const unsigned char>(0);
19
20public:
22 LifetimeOwner() = default;
23 LifetimeOwner(const LifetimeOwner&) = delete;
26 void reset() noexcept { state_.reset(); }
28 [[nodiscard]] LifetimeWitness witness() const noexcept {
30 result.state_ = state_;
31 return result;
32 }
33};
34} // namespace eve
Poco::JSON::Object::Ptr result
Sole owner of an opaque lifetime record; copying is forbidden.
LifetimeOwner & operator=(const LifetimeOwner &)=delete
void reset() noexcept
Invalidate witnesses without callbacks.
LifetimeWitness witness() const noexcept
Copy a witness without granting shared ownership.
LifetimeOwner()=default
Allocate a lifetime record at owner construction.
LifetimeOwner(const LifetimeOwner &)=delete
Owner-thread lifetime observation; cannot retain or access its owner.
bool isAlive() const noexcept
Query original owner liveness; owner-thread only.
LifetimeWitness()=default
Construct an invalid witness.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16