Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. General talk
  3. Brainstorm
  4. Thread-safe singleton
Qt 6.11 is out! See what's new in the release blog

Thread-safe singleton

Scheduled Pinned Locked Moved Brainstorm
4 Posts 2 Posters 5.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ? Offline
    ? Offline
    A Former User
    wrote on last edited by
    #1

    I would like to hear your criticism about "this":http://developer.qt.nokia.com/wiki/Qt_thread-safe_singleton article.

    1 Reply Last reply
    0
    • ? Offline
      ? Offline
      A Former User
      wrote on last edited by
      #2

      I think that
      @static T& instance()@

      should become
      @static const T& instance()@

      UPD: And i think that you need to explain in that article what do you need call_once for, since this is a wiki page.

      1 Reply Last reply
      0
      • ? Offline
        ? Offline
        A Former User
        wrote on last edited by
        #3

        Why reference to T must be const, what if user want change internal state of class?

        call_once it's thread-safe alternative for Double-Checked Locking pattern.

        1 Reply Last reply
        0
        • ? Offline
          ? Offline
          A Former User
          wrote on last edited by
          #4

          [quote author="SABROG" date="1282146241"]Why reference to T must be const, what if user want change internal state of class?[/quote]

          Yep, you are right. My fault.

          [quote author="SABROG" date="1282146241"]call_once it's thread-safe alternative for Double-Checked Locking pattern.[/quote]

          I read about it :). What I meant is towrite just a few words of description on that page, so there is not just naked code.

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved