Uploaded image for project: 'Apache Arrow'
  1. Apache Arrow
  2. ARROW-7464

[C++] Refine CpuInfo singleton with std::call_once

Agile BoardAttach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • None
    • 0.16.0
    • C++
    • Patch

    Description

      CpuInfo singleton is created and initialized on first invocation of
      CpuInfo::GetInstance(). All calls afterwards return reference to the
      same instance. Current code uses std::mutex to make sure that CpuInfo
      is created only once, but it introduces unnecessary overhead for later
      calls. Concurrent threads getting the created instance should not block
      each other.

      Replace std::mutex with std::call_once to fix this issue.

      References:
      [1] https://en.cppreference.com/w/cpp/thread/call_once
      [2] http://www.modernescpp.com/index.php/thread-safe-initialization-of-data

      Attachments

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            yibocai Yibo Cai Assign to me
            yibocai Yibo Cai
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 50m
                50m

                Slack

                  Issue deployment