You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Tim Brooks (JIRA)" <ji...@apache.org> on 2015/07/07 07:01:04 UTC
[jira] [Updated] (KAFKA-2312) Use AtomicLong opposed to
AtomicReference to store currentThread in consumer
[ https://issues.apache.org/jira/browse/KAFKA-2312?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Tim Brooks updated KAFKA-2312:
------------------------------
Assignee: Tim Brooks
Status: Patch Available (was: Open)
> 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
> 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)