载入中...
搜索中...
未找到
Subscription.cpp
浏览该文件的文档.
2
3#include <utility>
4
5namespace eve {
6
7Subscription::Subscription(Cancel cancel) : cancel_(std::move(cancel)), disposed_(!cancel_) {}
8
10 : cancel_(std::move(other.cancel_)), disposed_(other.disposed_) {
11 other.disposed_ = true;
12}
13
15 if (this == &other) return *this;
16 dispose();
17 cancel_ = std::move(other.cancel_);
18 disposed_ = other.disposed_;
19 other.disposed_ = true;
20 return *this;
21}
22
24
25void Subscription::dispose() noexcept {
26 if (disposed_) return;
27 disposed_ = true;
28 if (!cancel_) return;
29 auto cancel = std::move(cancel_);
30 cancel();
31}
32
33} // namespace eve
Move-only RAII token that owns one observer registration.
Subscription() noexcept=default
Creates an inactive token.
Subscription & operator=(const Subscription &)=delete
~Subscription()
Subscription.
std::function< void()> Cancel
void dispose() noexcept
Cancels this registration; safe to call repeatedly.
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16