Mantid
Loading...
Searching...
No Matches
EventWorkspaceMRU.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2011 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidDataObjects/DllConfig.h"
10#include "MantidHistogramData/HistogramE.h"
11#include "MantidHistogramData/HistogramY.h"
15
16#include "Poco/RWLock.h"
17
18#include <cstdint>
19#include <vector>
20
21namespace Mantid {
22namespace DataObjects {
23
24class EventList;
25
26//============================================================================
27//============================================================================
32template <class T> class TypeWithMarker {
33public:
38 TypeWithMarker(const uintptr_t the_index) : m_index(the_index) {}
39 TypeWithMarker(const TypeWithMarker &other) = delete;
40 TypeWithMarker &operator=(const TypeWithMarker &other) = delete;
41
42public:
44 uintptr_t m_index;
45
48
50 uintptr_t hashIndexFunction() const { return m_index; }
51
53 void setIndex(const uintptr_t the_index) { m_index = the_index; }
54};
55
56//============================================================================
57//============================================================================
61class MANTID_DATAOBJECTS_DLL EventWorkspaceMRU {
62public:
67 // Typedef for a Most-Recently-Used list of Data objects.
70
72
73 void ensureEnoughBuffersY(size_t thread_num) const;
74 void ensureEnoughBuffersE(size_t thread_num) const;
75
76 void clear();
77
78 YType findY(size_t thread_num, const EventList *index);
79 EType findE(size_t thread_num, const EventList *index);
80 void insertY(size_t thread_num, YType data, const EventList *index);
81 void insertE(size_t thread_num, EType data, const EventList *index);
82
83 void deleteIndex(const EventList *index);
84
88 size_t MRUSize() const;
89
90protected:
92 mutable std::vector<std::unique_ptr<mru_listY>> m_bufferedDataY;
93
95 mutable std::vector<std::unique_ptr<mru_listE>> m_bufferedDataE;
96
98 mutable Poco::RWLock m_changeMruListsMutexE;
99 mutable Poco::RWLock m_changeMruListsMutexY;
100};
101
102} // namespace DataObjects
103} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
A class for holding :
Definition EventList.h:57
This is a container for the MRU (most-recently-used) list of generated histograms.
Kernel::MRUList< EWithMarker > mru_listE
Poco::RWLock m_changeMruListsMutexE
Mutex when adding entries in the MRU list.
std::vector< std::unique_ptr< mru_listE > > m_bufferedDataE
The most-recently-used list of dataE histograms.
std::vector< std::unique_ptr< mru_listY > > m_bufferedDataY
The most-recently-used list of dataY histograms.
Kernel::MRUList< YWithMarker > mru_listY
This little class holds data and an index marker that is used for uniqueness.
void setIndex(const uintptr_t the_index)
Set the unique index value.
uintptr_t m_index
Unique index value.
TypeWithMarker(const TypeWithMarker &other)=delete
TypeWithMarker & operator=(const TypeWithMarker &other)=delete
T m_data
Pointer to a vector of data.
TypeWithMarker(const uintptr_t the_index)
Constructor.
uintptr_t hashIndexFunction() const
Function returns a unique index, used for hashing for MRU list.
An MRU (most recently used) list keeps record of the last n inserted items, listing first the newer o...
Definition MRUList.h:32
Implements a copy on write data template.
Definition cow_ptr.h:41
Helper class which provides the Collimation Length for SANS instruments.