[llvm-bugs] [Bug 44152] New: Change std::call_once to use per-flag lock rather than global lock

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Nov 26 08:37:39 PST 2019


https://bugs.llvm.org/show_bug.cgi?id=44152

            Bug ID: 44152
           Summary: Change std::call_once to use per-flag lock rather than
                    global lock
           Product: libc++
           Version: unspecified
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: All Bugs
          Assignee: unassignedclangbugs at nondot.org
          Reporter: dehuan at motorola.com
                CC: llvm-bugs at lists.llvm.org, mclow.lists at gmail.com

In libc++, std::call_once uses a global lock. This seems like a poor design
choice.

Code here:
https://github.com/llvm/llvm-project/blob/master/libcxx/src/mutex.cpp#L226

Previously MSVC also used global lock but it was changed in 2015:
https://devblogs.microsoft.com/cppblog/stl-fixes-in-vs-2015-part-2/

More story:
https://stackoverflow.com/questions/22692783/is-stdcall-once-reentrant-and-thread-safe
https://stackoverflow.com/questions/26477070/concurrent-stdcall-once-calls

For scalability, I believe there should be one mutex per std::once_flag.

-- 
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20191126/5bdcc4e9/attachment.html>


More information about the llvm-bugs mailing list