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"
14#include "MantidKernel/System.h"
16
17#include "Poco/RWLock.h"
18
19#include <cstdint>
20#include <vector>
21
22namespace Mantid {
23namespace DataObjects {
24
25class EventList;
26
27//============================================================================
28//============================================================================
33template <class T> class TypeWithMarker {
34public:
39 TypeWithMarker(const uintptr_t the_index) : m_index(the_index) {}
40 TypeWithMarker(const TypeWithMarker &other) = delete;
41 TypeWithMarker &operator=(const TypeWithMarker &other) = delete;
42
43public:
45 uintptr_t m_index;
46
49
51 uintptr_t hashIndexFunction() const { return m_index; }
52
54 void setIndex(const uintptr_t the_index) { m_index = the_index; }
55};
56
57//============================================================================
58//============================================================================
62class MANTID_DATAOBJECTS_DLL EventWorkspaceMRU {
63public:
68 // Typedef for a Most-Recently-Used list of Data objects.
71
73
74 void ensureEnoughBuffersY(size_t thread_num) const;
75 void ensureEnoughBuffersE(size_t thread_num) const;
76
77 void clear();
78
79 YType findY(size_t thread_num, const EventList *index);
80 EType findE(size_t thread_num, const EventList *index);
81 void insertY(size_t thread_num, YType data, const EventList *index);
82 void insertE(size_t thread_num, EType data, const EventList *index);
83
84 void deleteIndex(const EventList *index);
85
89 size_t MRUSize() const;
90
91protected:
93 mutable std::vector<std::unique_ptr<mru_listY>> m_bufferedDataY;
94
96 mutable std::vector<std::unique_ptr<mru_listE>> m_bufferedDataE;
97
99 mutable Poco::RWLock m_changeMruListsMutexE;
100 mutable Poco::RWLock m_changeMruListsMutexY;
101};
102
103} // namespace DataObjects
104} // namespace Mantid
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
A class for holding :
Definition: EventList.h:56
This is a container for the MRU (most-recently-used) list of generated histograms.
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.
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.