Skip to content
Snippets Groups Projects
Commit ecc8f631 authored by Edward Moyse's avatar Edward Moyse
Browse files

Merge branch 'IDCClassTraits' into 'master'

IDC: Class trait tweak

See merge request atlas/athena!35673
parents 0e1936bb 8c0a7c51
No related branches found
No related tags found
No related merge requests found
......@@ -8,7 +8,6 @@
#include "Identifier/IdentifierHash.h"
#include "GaudiKernel/StatusCode.h"
#include <vector>
#include <utility>
namespace EventContainers{
class IDC_WriteHandleBase;
......@@ -22,9 +21,19 @@ virtualised.
A standard iterator is provided for fast iteration in a sequential order.
*/
template<typename T>
struct hashPair{
IdentifierHash::value_type first;
const T* second;
constexpr hashPair(IdentifierHash::value_type f, const T* s) : first(f), second(s) { }
bool operator <(const hashPair &b) const noexcept{
return first < b.first;
}
};
class I_InternalIDC{
public:
typedef std::pair < IdentifierHash::value_type, const void* > hashPair;
typedef EventContainers::hashPair<void> hashPair;
typedef std::vector < hashPair >::const_iterator InternalConstItr;
#include "EventContainers/deleter.h"
virtual InternalConstItr cbegin() const=0;
......
......@@ -215,9 +215,10 @@ public:
return IdentifiableContainerBase::numberOfCollections();
}
const std::vector < std::pair<IdentifierHash::value_type, const T*> >& GetAllHashPtrPair() const{
const std::vector < EventContainers::hashPair<T> >& GetAllHashPtrPair() const{
static_assert(sizeof(const T*) == sizeof(const void*) && std::is_pointer<const T*>::value);
return reinterpret_cast<const std::vector < std::pair<IdentifierHash::value_type, const T*> >&>
static_assert(sizeof(EventContainers::hashPair<T>) == sizeof(EventContainers::hashPair<void>));
return reinterpret_cast<const std::vector < EventContainers::hashPair<T> >&>
(m_link->getAllHashPtrPair());
}
......
......@@ -38,7 +38,7 @@ public:
virtual void* removeCollection( IdentifierHash hashId ) override;
virtual void destructor(deleter_f*) noexcept override;
private:
std::vector<std::pair<IdentifierHash::value_type, const void*>> m_map;
std::vector<I_InternalIDC::hashPair> m_map;
size_t m_maximumSize;
};
......
......@@ -39,7 +39,7 @@ public:
virtual void* removeCollection( IdentifierHash hashId ) override;
virtual void destructor(deleter_f*) noexcept override;
private:
mutable std::vector<std::pair<IdentifierHash::value_type, const void*>> m_map;
mutable std::vector<I_InternalIDC::hashPair> m_map;
std::vector<const void*> m_fullMap;
mutable std::mutex m_waitMutex ATLAS_THREAD_SAFE;
mutable std::atomic<bool> m_needsupdate ATLAS_THREAD_SAFE; //These mutables are carefully thought out, do not change
......
......@@ -40,7 +40,7 @@ public:
virtual void* removeCollection( IdentifierHash hashId ) override;
virtual void destructor(deleter_f*) noexcept override;
private:
mutable std::vector<std::pair<IdentifierHash::value_type, const void*>> m_map;
mutable std::vector<I_InternalIDC::hashPair> m_map;
std::unordered_map<IdentifierHash::value_type, const void*> m_fullMap;
mutable std::mutex m_waitMutex ATLAS_THREAD_SAFE;
mutable std::atomic<bool> m_needsupdate ATLAS_THREAD_SAFE; //These mutables are carefully thought out, do not change
......
......@@ -49,7 +49,7 @@ public:
private:
EventContainers::IdentifiableCacheBase *m_cacheLink;
mutable std::vector< IdentifierHash > m_waitlist ATLAS_THREAD_SAFE;
mutable std::vector<std::pair<IdentifierHash::value_type, const void*>> m_map ATLAS_THREAD_SAFE;
mutable std::vector<I_InternalIDC::hashPair> m_map ATLAS_THREAD_SAFE;
mutable std::mutex m_waitMutex ATLAS_THREAD_SAFE;
mutable std::vector<bool> m_mask ATLAS_THREAD_SAFE;
mutable std::atomic<bool> m_waitNeeded ATLAS_THREAD_SAFE; //These mutables are carefully thought out, do not change
......
......@@ -9,7 +9,13 @@
using namespace EventContainers;
typedef I_InternalIDC::InternalConstItr InternalConstItr;
InternalOffline::InternalOffline(size_t max) : m_maximumSize(max) {}
InternalOffline::InternalOffline(size_t max) : m_maximumSize(max) {
//Check optimization assumptions
static_assert(std::is_trivially_copyable<hashPair>::value);
static_assert(std::is_trivially_destructible<hashPair>::value);
static_assert(std::is_trivially_copyable<IdentifierHash>::value);
static_assert(std::is_trivially_destructible<IdentifierHash>::value);
}
bool InternalOffline::tryAddFromCache(IdentifierHash hash, EventContainers::IDC_WriteHandleBase&) {
......
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