Skip to content
Snippets Groups Projects
Commit 55a80e15 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'thread4.AthContainers-20171213' into 'master'

AthContainers: Thread-safety fixes.

See merge request atlas/athena!7385
parents 6d7d7eeb f14d6889
1 merge request!20779WIP: Migrate DataQualityTools to ToolHandles
......@@ -13,6 +13,7 @@
*/
#include "CxxUtils/checker_macros.h"
#include <boost/iterator/transform_iterator.hpp>
#include <functional>
......@@ -26,7 +27,10 @@ class remove_const
: public std::unary_function<const T*, T*>
{
public:
T* operator() (const T* p) const { return const_cast<T*> (p); }
T* operator() (const T* p) const {
T* pp ATLAS_THREAD_SAFE = const_cast<T*> (p);
return pp;
}
};
......@@ -458,7 +462,8 @@ template <class DV>
inline
void ConstDataVector<DV>::push_back(value_type pElem)
{
DV::push_back (const_cast<typename DV::value_type> (pElem));
typename DV::value_type p ATLAS_THREAD_SAFE = const_cast<typename DV::value_type> (pElem);
DV::push_back (p);
}
......@@ -500,9 +505,9 @@ inline
typename ConstDataVector<DV>::iterator
ConstDataVector<DV>::insert(iterator position, value_type pElem)
{
typename DV::value_type p ATLAS_THREAD_SAFE = const_cast<typename DV::value_type> (pElem);
return to_my_iterator
(DV::insert (to_base_iterator (position),
const_cast<typename DV::value_type> (pElem)));
(DV::insert (to_base_iterator (position), p));
}
......@@ -743,9 +748,9 @@ ConstDataVector<DV>::swapElement (size_type index,
value_type newElem,
reference oldElem)
{
DV::swapElement (index,
const_cast<typename DV::value_type>(newElem),
const_cast<typename DV::reference>(oldElem));
typename DV::value_type pnew ATLAS_THREAD_SAFE = const_cast<typename DV::value_type>(newElem);
typename DV::reference rold ATLAS_THREAD_SAFE = const_cast<typename DV::reference>(oldElem);
DV::swapElement (index, pnew, rold);
}
......@@ -773,9 +778,9 @@ ConstDataVector<DV>::swapElement (iterator pos,
value_type newElem,
reference oldElem)
{
DV::swapElement (to_base_iterator(pos),
const_cast<typename DV::value_type>(newElem),
const_cast<typename DV::reference>(oldElem));
typename DV::value_type pnew ATLAS_THREAD_SAFE = const_cast<typename DV::value_type>(newElem);
typename DV::reference rold ATLAS_THREAD_SAFE = const_cast<typename DV::reference>(oldElem);
DV::swapElement (to_base_iterator(pos), pnew, rold);
}
......@@ -807,8 +812,9 @@ ConstDataVector<DV>::swapElement (size_type index,
std::unique_ptr<const base_value_type> newElem,
std::unique_ptr<const base_value_type>& oldElem)
{
std::unique_ptr<typename DV::base_value_type> new_u
(const_cast<typename DV::value_type> (newElem.release()));
typename DV::value_type pelem ATLAS_THREAD_SAFE =
const_cast<typename DV::value_type> (newElem.release());
std::unique_ptr<typename DV::base_value_type> new_u (pelem);
std::unique_ptr<typename DV::base_value_type> old_u;
DV::swapElement (index, std::move(new_u), old_u);
oldElem = std::move (old_u);
......@@ -841,8 +847,9 @@ ConstDataVector<DV>::swapElement (iterator pos,
std::unique_ptr<const base_value_type> newElem,
std::unique_ptr<const base_value_type>& oldElem)
{
std::unique_ptr<typename DV::base_value_type> new_u
(const_cast<typename DV::value_type> (newElem.release()));
typename DV::value_type pelem ATLAS_THREAD_SAFE =
const_cast<typename DV::value_type> (newElem.release());
std::unique_ptr<typename DV::base_value_type> new_u (pelem);
std::unique_ptr<typename DV::base_value_type> old_u;
DV::swapElement (to_base_iterator(pos), std::move(new_u), old_u);
oldElem = std::move (old_u);
......@@ -1037,7 +1044,9 @@ void
ConstDataVector<DV>::assignElement (typename BaseContainer::iterator pos,
value_type newElem)
{
DV::assignElement (pos, const_cast<typename DV::value_type> (newElem));
typename DV::value_type pelem ATLAS_THREAD_SAFE =
const_cast<typename DV::value_type> (newElem);
DV::assignElement (pos, pelem);
}
......@@ -1057,8 +1066,9 @@ void
ConstDataVector<DV>::assignElement (typename BaseContainer::iterator pos,
std::unique_ptr<const base_value_type> newElem)
{
std::unique_ptr<typename DV::base_value_type> new_u
(const_cast<typename DV::value_type> (newElem.release()));
typename DV::value_type pelem ATLAS_THREAD_SAFE =
const_cast<typename DV::value_type> (newElem.release());
std::unique_ptr<typename DV::base_value_type> new_u (pelem);
DV::assignElement (pos, std::move(new_u));
}
#endif
......
......@@ -24,6 +24,7 @@
#include "AthLinks/ElementLink.h"
#include "CxxUtils/unused.h"
#include "boost/preprocessor/stringize.hpp"
#include <atomic>
/**
......@@ -305,7 +306,8 @@ struct ClassID_traits< ViewVector<DV> >
static const CLID& ID() {
if (s_clid == CLID_NULL)
SG::throwExcMissingViewVectorCLID (typeid(ViewVector<DV>));
return s_clid;
static const CLID clid = s_clid;
return clid;
}
static const char* typeNameString() {
if (s_name == nullptr)
......@@ -334,14 +336,14 @@ struct ClassID_traits< ViewVector<DV> >
return true;
}
private:
static CLID s_clid;
static const char* s_name;
static std::atomic<CLID> s_clid;
static std::atomic<const char*> s_name;
};
template <class DV>
CLID ClassID_traits< ViewVector<DV> >::s_clid = CLID_NULL;
std::atomic<CLID> ClassID_traits< ViewVector<DV> >::s_clid { CLID_NULL };
template <class DV>
const char* ClassID_traits< ViewVector<DV> >::s_name = nullptr;
std::atomic<const char*> ClassID_traits< ViewVector<DV> >::s_name { nullptr };
#endif // not XAOD_STANDALONE
......
......@@ -12,6 +12,7 @@
#include "AthContainers/AuxElement.h"
#include "CxxUtils/checker_macros.h"
#include <type_traits>
......@@ -187,7 +188,8 @@ void ViewVectorBase::doToTransient2 (DV& v, const std::true_type&)
for (size_t i = 0; i < m_persKey.size(); i++) {
ElementLink<DV> el (m_persKey[i], m_persIndex[i], store);
// FIXME: const_cast
v.push_back (const_cast<typename DV::value_type> (*el));
typename DV::value_type p ATLAS_THREAD_SAFE = const_cast<typename DV::value_type> (*el);
v.push_back (p);
}
}
......
......@@ -16,6 +16,7 @@
#include "AthContainers/OwnershipPolicy.h"
#include "CxxUtils/checker_macros.h"
#include <vector>
#include <list>
#include <cassert>
......@@ -365,7 +366,7 @@ void* dvl_convert (const T& src,
typename T::const_iterator it = src.begin();
typename T::const_iterator end = src.end();
for (; it != end; ++it) {
Elt* elt = const_cast<Elt*> (*it);
Elt* elt ATLAS_THREAD_SAFE = const_cast<Elt*> (*it);
targ_info.push (newcont, castfn (elt));
}
......@@ -467,7 +468,7 @@ void dvl_update (const T& src,
typename T::const_iterator it = src.begin();
typename T::const_iterator end = src.end();
for (; it != end; ++it) {
Elt* elt = const_cast<Elt*> (*it);
Elt* elt ATLAS_THREAD_SAFE = const_cast<Elt*> (*it);
targ_info->push (target, castfn (elt));
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment