react-native-nitro-modules 0.33.4 → 0.33.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,8 +25,10 @@ std::string ThreadUtils::getThreadName() {
25
25
  }
26
26
 
27
27
  void ThreadUtils::setThreadName(const std::string& name) {
28
- auto jName = jni::make_jstring(name);
29
- JThreadUtils::setCurrentThreadName(jName);
28
+ jni::ThreadScope::WithClassLoader([&]() {
29
+ auto jName = jni::make_jstring(name);
30
+ JThreadUtils::setCurrentThreadName(jName);
31
+ });
30
32
  }
31
33
 
32
34
  bool ThreadUtils::isUIThread() {
@@ -164,28 +164,28 @@ AnyValue AnyMap::getAny(const std::string& key) const {
164
164
 
165
165
  // Set
166
166
  void AnyMap::setNull(const std::string& key) {
167
- _map.emplace(key, nitro::null);
167
+ _map.insert_or_assign(key, nitro::null);
168
168
  }
169
169
  void AnyMap::setDouble(const std::string& key, double value) {
170
- _map.emplace(key, value);
170
+ _map.insert_or_assign(key, value);
171
171
  }
172
172
  void AnyMap::setBoolean(const std::string& key, bool value) {
173
- _map.emplace(key, value);
173
+ _map.insert_or_assign(key, value);
174
174
  }
175
175
  void AnyMap::setBigInt(const std::string& key, int64_t value) {
176
- _map.emplace(key, value);
176
+ _map.insert_or_assign(key, value);
177
177
  }
178
178
  void AnyMap::setString(const std::string& key, const std::string& value) {
179
- _map.emplace(key, value);
179
+ _map.insert_or_assign(key, value);
180
180
  }
181
181
  void AnyMap::setArray(const std::string& key, const AnyArray& value) {
182
- _map.emplace(key, value);
182
+ _map.insert_or_assign(key, value);
183
183
  }
184
184
  void AnyMap::setObject(const std::string& key, const AnyObject& value) {
185
- _map.emplace(key, value);
185
+ _map.insert_or_assign(key, value);
186
186
  }
187
187
  void AnyMap::setAny(const std::string& key, const AnyValue& value) {
188
- _map.emplace(key, value);
188
+ _map.insert_or_assign(key, value);
189
189
  }
190
190
 
191
191
  // C++ getter
@@ -60,16 +60,12 @@ public:
60
60
  static std::shared_ptr<Prototype> get(const NativeInstanceId& typeId, const std::shared_ptr<Prototype>& base = nullptr) {
61
61
  static std::unordered_map<NativeInstanceId, std::shared_ptr<Prototype>> _prototypesCache;
62
62
 
63
- const auto& found = _prototypesCache.find(typeId);
64
- if (found != _prototypesCache.end()) {
65
- // We know this C++ type ID / Prototype - return it!
66
- return found->second;
67
- } else {
63
+ auto [it, inserted] = cache.try_emplace(typeId);
64
+ if (inserted) {
68
65
  // This is the first time we see this C++ type ID - create a new base Prototype for this.
69
- auto prototype = std::shared_ptr<Prototype>(new Prototype(typeId, base));
70
- _prototypesCache.emplace(typeId, prototype);
71
- return prototype;
66
+ it->second = std::shared_ptr<Prototype>(new Prototype(typeId, base));
72
67
  }
68
+ return it->second;
73
69
  }
74
70
 
75
71
  public:
@@ -64,12 +64,12 @@ void ThreadPool::run(std::function<void()>&& task) {
64
64
  }
65
65
  // New scope because of RAII lock
66
66
  {
67
- // lock on the mutex - we want to emplace the task back in the queue
67
+ // lock on the mutex - we want to push the task back in the queue
68
68
  std::unique_lock<std::mutex> lock(_queueMutex);
69
69
  if (!_isAlive) {
70
70
  throw std::runtime_error("Cannot queue the given task - the ThreadPool has already been stopped!");
71
71
  }
72
- _tasks.emplace(std::move(task));
72
+ _tasks.push(std::move(task));
73
73
  }
74
74
  // Notify about a new task - one of the workers will pick it up
75
75
  _condition.notify_one();
@@ -9,7 +9,7 @@
9
9
  #define NitroDefines_h
10
10
 
11
11
  // Sets the version of the native Nitro core library
12
- #define NITRO_VERSION "0.33.4"
12
+ #define NITRO_VERSION "0.33.6"
13
13
 
14
14
  // Sets whether to use debug or optimized production build flags
15
15
  #ifdef DEBUG
@@ -33,7 +33,7 @@ const jsi::PropNameID& PropNameIDCache::get(jsi::Runtime& runtime, const std::st
33
33
  auto sharedPropName = jsiCache.makeShared(std::move(propName));
34
34
 
35
35
  // store it in cache...
36
- cache.emplace(value, sharedPropName);
36
+ cache.insert_or_assign(value, sharedPropName);
37
37
 
38
38
  // return it!
39
39
  return *sharedPropName;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-nitro-modules",
3
- "version": "0.33.4",
3
+ "version": "0.33.6",
4
4
  "description": "Insanely fast native C++, Swift or Kotlin modules with a statically compiled binding layer to JSI.",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",