[
https://issues.apache.org/jira/browse/ARTEMIS-1356?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16136743#comment-16136743
]
ASF GitHub Bot commented on ARTEMIS-1356:
-----------------------------------------
Github user michaelandrepearce commented on a diff in the pull request:
https://github.com/apache/activemq-artemis/pull/1477#discussion_r134469939
--- Diff:
artemis-server/src/main/java/org/apache/activemq/artemis/core/protocol/core/ServerSessionPacketHandler.java
---
@@ -159,7 +158,11 @@
private final boolean direct;
- private static final ThreadLocal<AtomicBoolean> inHandler =
ThreadLocal.withInitial(AtomicBoolean::new);
+ //marker instance used to recognize if a thread is performing a packet
handling
+ private static final Object DUMMY = Boolean.TRUE;
+
+ //a thread that has its thread-local map populated with DUMMY is
performing a packet handling
+ private static final ThreadLocal<Object> inHandler = new
ThreadLocal<>();
--- End diff --
Fair doosies. Maybe a nit if that's the case why not make it Object() this
way stops any inference the boolean is being used as a true false flag. Which
I'll be honest is what I was thinking this was.
> Avoid allocations and atomic operations to recognize handler's thread
> ---------------------------------------------------------------------
>
> Key: ARTEMIS-1356
> URL: https://issues.apache.org/jira/browse/ARTEMIS-1356
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Components: Broker
> Reporter: Francesco Nigro
> Assignee: Francesco Nigro
>
> The current way to recognize the handler's thread is using heavyweight
> operations (allocations + atomic set/get) that limit some compiler
> optimizations on the (core) packet handling path.
> The same logic can be achieved using only a ThreadLocal map and a cached
> marker instance.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)