proxygen
Observable.h
Go to the documentation of this file.
1 /*
2  * Copyright 2016-present Facebook, Inc.
3  *
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
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
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.
15  */
16 #pragma once
17 
19 
20 namespace folly {
21 namespace observer {
22 
23 namespace detail {
24 template <typename Observable, typename Traits>
25 class ObserverCreatorContext;
26 }
27 
28 template <typename Observable>
30  using element_type =
31  typename std::remove_reference<Observable>::type::element_type;
32 
33  static std::shared_ptr<const element_type> get(Observable& observable) {
34  return observable.get();
35  }
36 
37  template <typename F>
38  static void subscribe(Observable& observable, F&& callback) {
39  observable.subscribe(std::forward<F>(callback));
40  }
41 
42  static void unsubscribe(Observable& observable) {
43  observable.unsubscribe();
44  }
45 };
46 
47 template <typename Observable, typename Traits = ObservableTraits<Observable>>
49  public:
50  using T = typename Traits::element_type;
51 
52  template <typename... Args>
53  explicit ObserverCreator(Args&&... args);
54 
55  Observer<T> getObserver() &&;
56 
57  private:
59 
60  std::shared_ptr<Context> context_;
61 };
62 } // namespace observer
63 } // namespace folly
64 
static void unsubscribe(Observable &observable)
Definition: Observable.h:42
internal::ArgsMatcher< InnerMatcher > Args(const InnerMatcher &matcher)
—— Concurrent Priority Queue Implementation ——
Definition: AtomicBitSet.h:29
typename Traits::element_type T
Definition: Observable.h:50
static std::shared_ptr< const element_type > get(Observable &observable)
Definition: Observable.h:33
std::shared_ptr< Context > context_
Definition: Observable.h:60
static void subscribe(Observable &observable, F &&callback)
Definition: Observable.h:38
typename std::remove_reference< Observable >::type::element_type element_type
Definition: Observable.h:31