From 6a7f9395dde570c8dc01ef489da9185170c52385 Mon Sep 17 00:00:00 2001 From: Andrii Grynenko Date: Thu, 25 Aug 2016 11:23:20 -0700 Subject: [PATCH] Fix SimplerObservable build with -Werror=unused-local-typedefs Reviewed By: yfeldblum Differential Revision: D3765642 fbshipit-source-id: 9b1cc4007c553da5082799fa4ed0af8f7850ec8d --- .../observer/SimpleObservable-inl.h | 35 ++++++++++--------- .../experimental/observer/SimpleObservable.h | 1 + 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/folly/experimental/observer/SimpleObservable-inl.h b/folly/experimental/observer/SimpleObservable-inl.h index 463e85bf..69fbf1a7 100644 --- a/folly/experimental/observer/SimpleObservable-inl.h +++ b/folly/experimental/observer/SimpleObservable-inl.h @@ -49,30 +49,31 @@ void SimpleObservable::setValue(std::shared_ptr value) { } template -Observer SimpleObservable::getObserver() { - struct SimpleObservableWrapper { - using element_type = T; +struct SimpleObservable::Wrapper { + using element_type = T; - std::shared_ptr context; + std::shared_ptr context; - std::shared_ptr get() { - return context->value_.copy(); - } + std::shared_ptr get() { + return context->value_.copy(); + } - void subscribe(folly::Function callback) { - context->callback_.swap(callback); - } + void subscribe(folly::Function callback) { + context->callback_.swap(callback); + } - void unsubscribe() { - folly::Function empty; - context->callback_.swap(empty); - } - }; + void unsubscribe() { + folly::Function empty; + context->callback_.swap(empty); + } +}; +template +Observer SimpleObservable::getObserver() { std::call_once(observerInit_, [&]() { - SimpleObservableWrapper wrapper; + SimpleObservable::Wrapper wrapper; wrapper.context = context_; - ObserverCreator creator(std::move(wrapper)); + ObserverCreator::Wrapper> creator(std::move(wrapper)); observer_ = std::move(creator).getObserver(); }); return *observer_; diff --git a/folly/experimental/observer/SimpleObservable.h b/folly/experimental/observer/SimpleObservable.h index 1feb21d2..ca05f9ad 100644 --- a/folly/experimental/observer/SimpleObservable.h +++ b/folly/experimental/observer/SimpleObservable.h @@ -38,6 +38,7 @@ class SimpleObservable { folly::Synchronized> value_; folly::Synchronized> callback_; }; + struct Wrapper; std::shared_ptr context_; std::once_flag observerInit_; -- 2.34.1