mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
5be44456f2
Summary: This is to prepare for enabling TurboModule on Android. This commit compiles in all the core files (C++) into the ReactAndroid NDK build step. This doesn't yet enable TurboModule by default, just compiling in the infra, just like for iOS. New shared libs: * libreact_nativemodule_core.so: The TurboModule Android core * libreact_nativemodule_manager.so: The TurboModule manager/delegate To be compatible with `<ReactCommon/` .h include prefix, the files had to move to local `ReactCommon` subdirs. Changelog: [Internal] Reviewed By: sammy-SC Differential Revision: D23805717 fbshipit-source-id: b41c392a592dd095ae003f7b2a689f4add2c37a9
57 lines
1.4 KiB
C++
57 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the
|
|
* LICENSE file in the root directory of this source tree.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <unordered_set>
|
|
|
|
namespace facebook {
|
|
namespace react {
|
|
|
|
/**
|
|
* A simple wrapper class that can be registered to a collection that keep it
|
|
* alive for extended period of time. This object can be removed from the
|
|
* collection when needed.
|
|
*
|
|
* The subclass of this class must be created using std::make_shared<T>().
|
|
* After creation, add it to the `LongLivedObjectCollection`.
|
|
* When done with the object, call `allowRelease()` to allow the OS to release
|
|
* it.
|
|
*/
|
|
class LongLivedObject {
|
|
public:
|
|
void allowRelease();
|
|
|
|
protected:
|
|
LongLivedObject();
|
|
};
|
|
|
|
/**
|
|
* A singleton, thread-safe, write-only collection for the `LongLivedObject`s.
|
|
*/
|
|
class LongLivedObjectCollection {
|
|
public:
|
|
static LongLivedObjectCollection &get();
|
|
|
|
LongLivedObjectCollection(LongLivedObjectCollection const &) = delete;
|
|
void operator=(LongLivedObjectCollection const &) = delete;
|
|
|
|
void add(std::shared_ptr<LongLivedObject> o) const;
|
|
void remove(const LongLivedObject *o) const;
|
|
void clear() const;
|
|
|
|
private:
|
|
LongLivedObjectCollection();
|
|
mutable std::unordered_set<std::shared_ptr<LongLivedObject>> collection_;
|
|
mutable std::mutex collectionMutex_;
|
|
};
|
|
|
|
} // namespace react
|
|
} // namespace facebook
|