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
QtWS25 Last Chance

Thread-safe singleton

Scheduled Pinned Locked Moved Brainstorm
4 Posts 2 Posters 4.5k Views
  • 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.
  • S Offline
    S Offline
    sabrog
    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.

    QT - Apple QuickTime
    Qt - Nokia's Qt Development Frameworks
    Apple is a competitor of Nokia, so QT != Qt

    1 Reply Last reply
    0
    • L Offline
      L Offline
      lyuts
      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.

      I'm a rebel in the S.D.G.

      1 Reply Last reply
      0
      • S Offline
        S Offline
        sabrog
        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.

        QT - Apple QuickTime
        Qt - Nokia's Qt Development Frameworks
        Apple is a competitor of Nokia, so QT != Qt

        1 Reply Last reply
        0
        • L Offline
          L Offline
          lyuts
          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.

          I'm a rebel in the S.D.G.

          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