[lldb-dev] Passing std::atomics by value
Greg Clayton via lldb-dev
lldb-dev at lists.llvm.org
Mon Aug 29 09:46:07 PDT 2016
> On Aug 29, 2016, at 8:56 AM, Zachary Turner <zturner at google.com> wrote:
> How about making it a std::unique_ptr<std::atomic<lldb::addr_t>>? This way there's no risk of re-introducing a potential race, and copying still works.
lldb_private::Address is a member variable in lldb_private::Symbol and it needs to say as small as possible as lldb_private::Symbol is the number one memory hog in LLDB. Adding a unique pointer would make each address now have two memory entries: one for the Address (on the stack or heap) and one for the std::atomic on the heap. Address needs to say simple. I agree with you that we should rely upon mutexes to take care of threading issues and that Address probably shouldn't have to use std::atomic. Lets try and get rid of the atomic and fix the code that was having the race by using appropriate threading constructs.
More information about the lldb-dev