Commit 64bb0d5
Hold lock while changing atomic running_ in TaskDispatchThread (facebook#54817)
Summary:
Pull Request resolved: facebook#54817
Changelog: [Internal]
Fixed a bug in TaskDispatchThread.
According to https://en.cppreference.com/w/cpp/thread/condition_variable.html:
> Even if the shared variable is atomic, it must be modified while owning the mutex to correctly publish the modification to the waiting thread.
So we need to own a lock when changing running_ in quit(). Otherwise, there is a chance that signal will get lost, which leads to deadlock on quit().
Also I did a minor refactoring by updating running_.compare_exchange_strong() to running_.exchange().
Reviewed By: javache
Differential Revision: D88640446
fbshipit-source-id: 364864d58787650a23d8f835b7874bda8d7626731 parent 9011316 commit 64bb0d5
File tree
2 files changed
+13
-6
lines changed- packages/react-native/ReactCxxPlatform/react/threading
2 files changed
+13
-6
lines changedLines changed: 12 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
70 | 70 | | |
71 | 71 | | |
72 | 72 | | |
73 | | - | |
| 73 | + | |
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
95 | | - | |
96 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
97 | 104 | | |
98 | 105 | | |
99 | 106 | | |
| |||
107 | 114 | | |
108 | 115 | | |
109 | 116 | | |
110 | | - | |
| 117 | + | |
111 | 118 | | |
112 | 119 | | |
113 | 120 | | |
| |||
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
61 | 61 | | |
62 | 62 | | |
63 | 63 | | |
64 | | - | |
| 64 | + | |
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
| |||
0 commit comments