Details

    • Type: Improvement Improvement
    • Status: Resolved
    • Priority: Trivial Trivial
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 3.5.0
    • Component/s: java client, server
    • Labels:
      None
    • Hadoop Flags:
      Reviewed
    • Tags:
      Atomic

      Description

      As I've read last weekend in the fantastic book "Clean Code", it'd be much faster to use AtomicInteger or AtomicLong instead of synchronization blocks around each access to an int or long.
      The key difference is, that a synchronization block will in any case acquire and release a lock. The atomic classes use "optimistic locking", a CPU operation that only changes a value if it still has not changed since the last read.
      In most cases the value has not changed since the last visit so the operation is just as fast as a normal operation. If it had changed, then we read again and try to change again.

      [1] Clean Code: A Handbook of Agile Software Craftsmanship (Robert C. Martin)

        Activity

        Thomas Koch created issue -
        Thomas Koch made changes -
        Field Original Value New Value
        Attachment ZOOKEEPER-955.patch [ 12465683 ]
        Thomas Koch made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Benjamin Reed made changes -
        Hadoop Flags [Reviewed]
        Mahadev konar made changes -
        Fix Version/s 3.4.0 [ 12314469 ]
        Mahadev konar made changes -
        Status Patch Available [ 10002 ] Open [ 1 ]
        Mahadev konar made changes -
        Fix Version/s 3.5.0 [ 12316644 ]
        Fix Version/s 3.4.0 [ 12314469 ]
        Michi Mutsuzaki made changes -
        Status Open [ 1 ] Resolved [ 5 ]
        Resolution Won't Fix [ 2 ]

          People

          • Assignee:
            Thomas Koch
            Reporter:
            Thomas Koch
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development