Fabric: Lock-free events 3/n: EventEmitter::DispatchMutex is not recursive mutex anymore

Summary: The mutex is a "leaf" mutex, so the code cannot reenter that, so there is no reason to be a recursive one.

Reviewed By: sahrens

Differential Revision: D13642592

fbshipit-source-id: 0fb64d3405c5d3408251dc983c186f6747bc6ee2
This commit is contained in:
Valentin Shergin 2019-01-16 20:17:01 -08:00 committed by Facebook Github Bot
parent b1814b37aa
commit 97f9e4082c
4 changed files with 5 additions and 5 deletions

View File

@ -31,8 +31,8 @@ static std::string normalizeEventType(const std::string &type) {
return prefixedType;
}
std::recursive_mutex &EventEmitter::DispatchMutex() {
static std::recursive_mutex mutex;
std::mutex &EventEmitter::DispatchMutex() {
static std::mutex mutex;
return mutex;
}

View File

@ -34,7 +34,7 @@ class EventEmitter {
using Tag = int32_t;
public:
static std::recursive_mutex &DispatchMutex();
static std::mutex &DispatchMutex();
static ValueFactory defaultPayloadFactory();

View File

@ -40,7 +40,7 @@ void EventQueue::onBeat(jsi::Runtime &runtime) const {
}
{
std::lock_guard<std::recursive_mutex> lock(EventEmitter::DispatchMutex());
std::lock_guard<std::mutex> lock(EventEmitter::DispatchMutex());
for (const auto &event : queue) {
if (event.eventTarget) {

View File

@ -155,7 +155,7 @@ void ShadowTree::emitLayoutEvents(
void ShadowTree::toggleEventEmitters(
const ShadowViewMutationList &mutations) const {
std::lock_guard<std::recursive_mutex> lock(EventEmitter::DispatchMutex());
std::lock_guard<std::mutex> lock(EventEmitter::DispatchMutex());
for (const auto &mutation : mutations) {
if (mutation.type == ShadowViewMutation::Create) {