mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Fabric: ContextContainer was moved to utils module
Summary: That allows avoiding circular deps and unnecessary deps on uimanager module. Reviewed By: PeteTheHeat Differential Revision: D14917227 fbshipit-source-id: fe7962ee528aa659d8bd23e3e46627722551d995
This commit is contained in:
committed by
Facebook Github Bot
parent
108c4190ed
commit
792585fd48
@@ -18,7 +18,7 @@
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -9,9 +9,9 @@
|
||||
|
||||
#import <react/debug/SystraceSection.h>
|
||||
#import <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#import <react/uimanager/ContextContainer.h>
|
||||
#import <react/uimanager/Scheduler.h>
|
||||
#import <react/uimanager/SchedulerDelegate.h>
|
||||
#import <react/utils/ContextContainer.h>
|
||||
|
||||
#import <React/RCTFollyConvert.h>
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#import <React/RCTComponentViewFactory.h>
|
||||
#import <React/RCTPrimitives.h>
|
||||
#import <react/config/ReactNativeConfig.h>
|
||||
#import <react/uimanager/ContextContainer.h>
|
||||
#import <react/utils/ContextContainer.h>
|
||||
|
||||
NS_ASSUME_NONNULL_BEGIN
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#import <react/core/LayoutConstraints.h>
|
||||
#import <react/core/LayoutContext.h>
|
||||
#import <react/imagemanager/ImageManager.h>
|
||||
#import <react/uimanager/ContextContainer.h>
|
||||
#import <react/utils/ContextContainer.h>
|
||||
|
||||
#import "MainRunLoopEventBeat.h"
|
||||
#import "RuntimeEventBeat.h"
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
#include <react/core/EventBeat.h>
|
||||
#include <react/core/EventEmitter.h>
|
||||
#include <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
#include <react/uimanager/Scheduler.h>
|
||||
#include <react/uimanager/SchedulerDelegate.h>
|
||||
#include <react/uimanager/primitives.h>
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
#include <fb/fbjni.h>
|
||||
#include <jsi/jsi.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
#include <react/uimanager/Scheduler.h>
|
||||
#include <mutex>
|
||||
#include <unordered_set>
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
#include <react/components/image/ImageShadowNode.h>
|
||||
#include <react/core/ConcreteComponentDescriptor.h>
|
||||
#include <react/imagemanager/ImageManager.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <react/core/ConcreteComponentDescriptor.h>
|
||||
#include <react/core/LayoutConstraints.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
#include <react/core/ConcreteComponentDescriptor.h>
|
||||
#include <react/core/LayoutConstraints.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -11,10 +11,10 @@
|
||||
#include "ParagraphShadowNode.h"
|
||||
|
||||
#include <folly/container/EvictingCacheMap.h>
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/core/ConcreteComponentDescriptor.h>
|
||||
#include <react/textlayoutmanager/TextLayoutManager.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
|
||||
#include <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <react/attributedstring/AttributedString.h>
|
||||
#include <react/attributedstring/ParagraphAttributes.h>
|
||||
#include <react/core/LayoutConstraints.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
#include <react/attributedstring/AttributedString.h>
|
||||
#include <react/attributedstring/ParagraphAttributes.h>
|
||||
#include <react/core/LayoutConstraints.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
#include <react/core/ComponentDescriptor.h>
|
||||
#include <react/core/EventDispatcher.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
#include "ComponentDescriptorRegistry.h"
|
||||
|
||||
|
||||
@@ -17,11 +17,11 @@
|
||||
#include <react/mounting/ShadowTreeRegistry.h>
|
||||
#include <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/uimanager/SchedulerDelegate.h>
|
||||
#include <react/uimanager/UIManagerBinding.h>
|
||||
#include <react/uimanager/UIManagerDelegate.h>
|
||||
#include <react/uimanager/primitives.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -23,7 +23,7 @@ using namespace facebook::react;
|
||||
#include <react/config/ReactNativeConfig.h>
|
||||
#include <react/uimanager/ComponentDescriptorFactory.h>
|
||||
#include <react/uimanager/ComponentDescriptorRegistry.h>
|
||||
#include <react/uimanager/ContextContainer.h>
|
||||
#include <react/utils/ContextContainer.h>
|
||||
|
||||
namespace facebook {
|
||||
namespace react {
|
||||
|
||||
@@ -8,10 +8,7 @@
|
||||
#include <memory>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <typeindex>
|
||||
#include <typeinfo>
|
||||
#include <unordered_map>
|
||||
#include <utility>
|
||||
|
||||
#include <glog/logging.h>
|
||||
|
||||
@@ -28,6 +25,8 @@ using SharedContextContainer = std::shared_ptr<ContextContainer>;
|
||||
*/
|
||||
class ContextContainer final {
|
||||
public:
|
||||
using Shared = std::shared_ptr<ContextContainer>;
|
||||
|
||||
/*
|
||||
* Registers an instance of the particular type `T` in the container
|
||||
* using the provided `key`. Only one instance can be registered per key.
|
||||
@@ -39,10 +38,10 @@ class ContextContainer final {
|
||||
*`EmptyReactNativeConfig`.
|
||||
*/
|
||||
template <typename T>
|
||||
void registerInstance(const T &instance, const std::string &key) {
|
||||
void registerInstance(T const &instance, std::string const &key) {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
const auto res = instances_.insert({key, std::make_shared<T>(instance)});
|
||||
auto res = instances_.insert({key, std::make_shared<T>(instance)});
|
||||
if (res.second == false) {
|
||||
LOG(FATAL) << "ContextContainer already had instance for key '" << key
|
||||
<< "'";
|
||||
@@ -54,7 +53,7 @@ class ContextContainer final {
|
||||
* for `key`.
|
||||
*/
|
||||
template <typename T>
|
||||
T getInstance(const std::string &key) const {
|
||||
T getInstance(std::string const &key) const {
|
||||
std::lock_guard<std::mutex> lock(mutex_);
|
||||
|
||||
return *std::static_pointer_cast<T>(instances_.at(key));
|
||||
Reference in New Issue
Block a user