2 * Copyright 2015 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
19 #include <folly/wangle/deprecated/rx/types.h> // must come first
20 #include <folly/wangle/deprecated/rx/Observable.h>
22 namespace folly { namespace wangle {
27 Subscription() = default;
29 Subscription(const Subscription&) = delete;
31 Subscription(Subscription&& other) noexcept {
32 *this = std::move(other);
35 Subscription& operator=(Subscription&& other) noexcept {
37 unsubscriber_ = std::move(other.unsubscriber_);
39 other.unsubscriber_ = nullptr;
49 typedef typename Observable<T>::Unsubscriber Unsubscriber;
51 Subscription(std::shared_ptr<Unsubscriber> unsubscriber, uint64_t id)
52 : unsubscriber_(std::move(unsubscriber)), id_(id) {
57 if (unsubscriber_ && id_ > 0) {
58 unsubscriber_->unsubscribe(id_);
60 unsubscriber_ = nullptr;
64 std::shared_ptr<Unsubscriber> unsubscriber_;
67 friend class Observable<T>;