1 // Dear emacs, this is -*- c++ -*-
3 // Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
5 #ifndef XAODROOTACCESS_TOOLS_TDESTRUCTORREGISTRY_ICC
6 #define XAODROOTACCESS_TOOLS_TDESTRUCTORREGISTRY_ICC
13 #include "xAODRootAccess/tools/TDestructor.h"
17 /// This function is used by the code to teach the registry about new
18 /// types that we want to be able to delete from a type agnostic piece
22 void TDestructorRegistry::add() {
25 const std::type_info& ti = typeid( T );
27 // Check if we already have a destructor for it:
30 std::shared_lock< std::shared_timed_mutex > lock( m_mutex );
31 if( m_types.find( &ti ) != m_types.end() ) {
32 // Yep, there's nothing to do...
37 // Get a "write lock":
38 std::unique_lock< std::shared_timed_mutex > lock( m_mutex );
40 // Create a new destructor object.
41 m_types[ &ti ] = std::make_unique< TDestructor< T > >();
48 #endif // XAODROOTACCESS_TOOLS_TDESTRUCTORREGISTRY_ICC