Tim Brooks created KAFKA-2312:
---------------------------------

             Summary: Use AtomicLong opposed to AtomicReference to store 
currentThread in consumer
                 Key: KAFKA-2312
                 URL: https://issues.apache.org/jira/browse/KAFKA-2312
             Project: Kafka
          Issue Type: Improvement
          Components: clients
            Reporter: Tim Brooks
            Priority: Minor


When a thread id is returned by Thread.currentThread().getId() it is a 
primitive. Storing it in an AtomicReference requires boxing and additional 
indirection.

An AtomicLong seems more natural to store a long. 

The current implementation relies on knowing that null means no owner. Since 
thread ids are always positive (specified in javadoc), it is possible to create 
a constant NO_CURRENT_THREAD for -1. Which allows the usage of an AtomicLong 
and makes the functionality explicit.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to