From 180c4b67a42e09b33f3c962b949cd7b9b1ef0787 Mon Sep 17 00:00:00 2001
From: Frank Winklmeier <frank.winklmeier@cern.ch>
Date: Fri, 25 Nov 2022 10:41:36 +0100
Subject: [PATCH] ExpressionEvaluation: thread-checker fixes

- suppress const_cast warnings (dictated by `TMethodCall` interface)
- remove TODO items as we are now using the thread-safe `TSMethodCall`)

Relates to ATLASRECTS-7369.
---
 .../Root/xAODVariableProxyLoaders.cxx              |  6 ++++--
 .../ExpressionEvaluation/src/MethodAccessor.h      | 14 ++++++--------
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/PhysicsAnalysis/CommonTools/ExpressionEvaluation/Root/xAODVariableProxyLoaders.cxx b/PhysicsAnalysis/CommonTools/ExpressionEvaluation/Root/xAODVariableProxyLoaders.cxx
index b2b78ee72faf..749fb0c3483c 100644
--- a/PhysicsAnalysis/CommonTools/ExpressionEvaluation/Root/xAODVariableProxyLoaders.cxx
+++ b/PhysicsAnalysis/CommonTools/ExpressionEvaluation/Root/xAODVariableProxyLoaders.cxx
@@ -129,14 +129,16 @@ namespace ExpressionParsing {
   int TMethodWrapper::getIntValue(const SG::AuxElement *auxElement) const
   {
     long retLong;
-    m_methodCall.call()->Execute((void *)auxElement, retLong);
+    auto aux_nc ATLAS_THREAD_SAFE = const_cast<SG::AuxElement*>(auxElement);  // required by TMethodCall
+    m_methodCall.call()->Execute(aux_nc, retLong);
     return (int) retLong;
   }
 
   double TMethodWrapper::getDoubleValue(const SG::AuxElement *auxElement) const
   {
     double retDouble;
-    m_methodCall.call()->Execute((void *)auxElement, retDouble);
+    auto aux_nc ATLAS_THREAD_SAFE = const_cast<SG::AuxElement*>(auxElement);  // required by TMethodCall
+    m_methodCall.call()->Execute(aux_nc, retDouble);
     return retDouble;
   }
 
diff --git a/PhysicsAnalysis/CommonTools/ExpressionEvaluation/src/MethodAccessor.h b/PhysicsAnalysis/CommonTools/ExpressionEvaluation/src/MethodAccessor.h
index 5bb9bf88a7a5..2c0582e9045a 100644
--- a/PhysicsAnalysis/CommonTools/ExpressionEvaluation/src/MethodAccessor.h
+++ b/PhysicsAnalysis/CommonTools/ExpressionEvaluation/src/MethodAccessor.h
@@ -47,17 +47,15 @@ namespace ExpressionParsing {
       T_src get(const T_Cont &/*cont*/) const {
          T_src ret;
          assert( m_collectionProxy->Size() == 1);
-         // @TODO root/cling lock needed  ?
-         m_methodCall.call()->Execute((*m_collectionProxy)[0], ret); // @TODO thread safe ?
+         m_methodCall.call()->Execute((*m_collectionProxy)[0], ret);
          return ret;
       }
 
       /// Get the specified element of the vector provided by the container
       T_src get(const T_Cont &/*cont*/, std::size_t idx) const {
          T_src ret;
-         // @TODO root/cling lock needed  ?
          void *element_data=(*m_collectionProxy)[idx];
-         m_methodCall.call()->Execute(element_data, ret); // @TODO thread safe ?
+         m_methodCall.call()->Execute(element_data, ret);
          return ret;
       }
 
@@ -105,8 +103,8 @@ namespace ExpressionParsing {
       /// Get the scalar provided by the container
       T_src get(const T_Cont &/*cont*/) const {
          T_src ret;
-         // @TODO root/cling lock needed  ?
-         m_methodCall.call()->Execute(const_cast<void *>(m_data), ret);
+         void* data_nc ATLAS_THREAD_SAFE = const_cast<void *>(m_data);  // required by TMethodCall
+         m_methodCall.call()->Execute(data_nc, ret);
          return ret;
       }
 
@@ -114,8 +112,8 @@ namespace ExpressionParsing {
       T_src get(const T_Cont &/*cont*/, [[maybe_unused]] std::size_t idx) const {
          T_src ret;
          assert( idx==0);
-         // @TODO root/cling lock needed  ?
-         m_methodCall.call()->Execute(const_cast<void *>(m_data), ret);
+         void* data_nc ATLAS_THREAD_SAFE = const_cast<void *>(m_data);  // required by TMethodCall
+         m_methodCall.call()->Execute(data_nc, ret);
          return ret;
       }
 
-- 
GitLab