Skip to content

Commit

Permalink
Merge equivalent of facebook#13994 - thread safety
Browse files Browse the repository at this point in the history
  • Loading branch information
cpirich committed Mar 16, 2018
1 parent 847a6f9 commit ea9a449
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public ShadowNodeRegistry() {
mThreadAsserter = new SingleThreadAsserter();
}

public void addRootNode(ReactShadowNode node) {
public synchronized void addRootNode(ReactShadowNode node) {
// TODO(6242243): This should be asserted... but UIManagerModule is
// thread-unsafe and calls this on the wrong thread.
//mThreadAsserter.assertNow();
Expand All @@ -38,7 +38,7 @@ public void addRootNode(ReactShadowNode node) {
mRootTags.put(tag, true);
}

public void removeRootNode(int tag) {
public synchronized void removeRootNode(int tag) {
mThreadAsserter.assertNow();
if (!mRootTags.get(tag)) {
throw new IllegalViewOperationException(
Expand All @@ -49,12 +49,12 @@ public void removeRootNode(int tag) {
mRootTags.delete(tag);
}

public void addNode(ReactShadowNode node) {
public synchronized void addNode(ReactShadowNode node) {
mThreadAsserter.assertNow();
mTagsToCSSNodes.put(node.getReactTag(), node);
}

public void removeNode(int tag) {
public synchronized void removeNode(int tag) {
mThreadAsserter.assertNow();
if (mRootTags.get(tag)) {
throw new IllegalViewOperationException(
Expand All @@ -63,22 +63,22 @@ public void removeNode(int tag) {
mTagsToCSSNodes.remove(tag);
}

public ReactShadowNode getNode(int tag) {
public synchronized ReactShadowNode getNode(int tag) {
mThreadAsserter.assertNow();
return mTagsToCSSNodes.get(tag);
}

public boolean isRootNode(int tag) {
public synchronized boolean isRootNode(int tag) {
mThreadAsserter.assertNow();
return mRootTags.get(tag);
}

public int getRootNodeCount() {
public synchronized int getRootNodeCount() {
mThreadAsserter.assertNow();
return mRootTags.size();
}

public int getRootTag(int index) {
public synchronized int getRootTag(int index) {
mThreadAsserter.assertNow();
return mRootTags.keyAt(index);
}
Expand Down

0 comments on commit ea9a449

Please sign in to comment.