[ 
https://issues.apache.org/jira/browse/KAFKA-2312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Guozhang Wang updated KAFKA-2312:
---------------------------------
       Resolution: Fixed
    Fix Version/s: 0.8.3
           Status: Resolved  (was: Patch Available)

> 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
>            Assignee: Tim Brooks
>            Priority: Minor
>             Fix For: 0.8.3
>
>         Attachments: KAFKA-2312.patch
>
>
> 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