Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make System::Layer::mHandleSelectThread atomic.
mHandleSelectThread is used for an optimization: when it's set to the current thread id, WakeIOThread knows that: 1) We're in the middle of running Layer::HandleTimeout 2) We're doing that on the same thread where WakeIOThread was called and hence WakeIOThread doesn't need to do anything, because we're already on the IO thread and it's already awake. The read of this member in WakeIOThread is not synchronized in any way, but as long as we guarantee that it correctly reads a value that was actually assigned to the member (which std::atomic does), things will work correctly. Either the value we read will be equal to the current thread id, in which case we know we're on the one thread that called Layer::HandleTimeout and are inside that function, or it will not be equal to our thread id and then we need to do the actual wakeup work, whatever that value is (including if it's null). Fixes project-chip#7818
- Loading branch information