react-native/ReactCommon/fabric/uimanager/ContextContainer.cpp
Valentin Shergin c674303dfd Fabric: Introducing ContextContainer
Summary:
@public
`ContextContainer` is general purpose DI container for Fabric.
We need this to communicate some enviroment-specific and/or platform-specific modules down to cross-platform C++ code.
The first one will be ImageManager. Soon.

Reviewed By: fkgozali

Differential Revision: D8475636

fbshipit-source-id: 0afc65063f818d0bab736cd2c55c6fdd21b629ac
2018-06-22 07:32:49 -07:00

23 lines
647 B
C++

// Copyright (c) 2004-present, Facebook, Inc.
// This source code is licensed under the MIT license found in the
// LICENSE file in the root directory of this source tree.
#include "ContextContainer.h"
namespace facebook {
namespace react {
void ContextContainer::registerInstance(const ClassHandle &handle, SharedInstance instance) {
std::lock_guard<std::mutex> lock(mutex_);
instances_.insert({handle, instance});
}
const ContextContainer::SharedInstance &ContextContainer::at(const ClassHandle &handle) const {
std::lock_guard<std::mutex> lock(mutex_);
return instances_.at(handle);
}
} // namespace react
} // namespace facebook