9#ifndef SequentialvtkSMPThreadLocalImpl_h
10#define SequentialvtkSMPThreadLocalImpl_h
25VTK_ABI_NAMESPACE_BEGIN
30 typedef std::vector<T> TLS;
31 typedef typename TLS::iterator TLSIter;
50 int tid = this->GetThreadID();
51 if (!this->Initialized[tid])
53 this->Internal[tid] = this->Exemplar;
54 this->Initialized[tid] =
true;
55 ++this->NumInitialized;
57 return this->Internal[tid];
60 size_t size()
const override {
return this->NumInitialized; }
72 while (this->InitIter != this->EndIter)
85 return this->Iter ==
static_cast<ItImpl*
>(other)->Iter;
97 std::vector<bool>::iterator InitIter;
98 std::vector<bool>::iterator EndIter;
102 std::unique_ptr<ItImplAbstract>
begin() override
104 TLSIter iter = this->Internal.begin();
105 std::vector<bool>::iterator iter2 = this->Initialized.begin();
106 std::vector<bool>::iterator enditer = this->Initialized.end();
109 while (iter2 != enditer)
119 auto retVal = std::unique_ptr<ItImpl>(
new ItImpl());
120 retVal->InitIter = iter2;
121 retVal->EndIter = enditer;
124 std::unique_ptr<ItImplAbstract> abstractIt(std::move(retVal));
128 std::unique_ptr<ItImplAbstract>
end()
override
131 auto retVal = std::unique_ptr<ItImpl>(
new ItImpl());
132 retVal->InitIter = this->Initialized.end();
133 retVal->EndIter = this->Initialized.end();
134 retVal->Iter = this->Internal.end();
136 std::unique_ptr<ItImplAbstract> abstractIt(std::move(retVal));
142 std::vector<bool> Initialized;
143 size_t NumInitialized;
148 this->Internal.resize(this->GetNumberOfThreads());
149 this->Initialized.resize(this->GetNumberOfThreads());
150 std::fill(this->Initialized.begin(), this->Initialized.end(),
false);
153 inline int GetNumberOfThreads() {
return 1; }
155 inline int GetThreadID() {
return 0; }
158 vtkSMPThreadLocalImpl(
const vtkSMPThreadLocalImpl&) =
delete;
159 void operator=(
const vtkSMPThreadLocalImpl&) =
delete;
ItImpl & operator=(const ItImpl &)=default
virtual std::unique_ptr< ItImpl > begin()=0
bool Compare(ItImplAbstract *other) override
ItImpl * CloneImpl() const override
T * GetContentPtr() override
void Increment() override
T & GetContent() override
vtkSMPThreadLocalImpl(const T &exemplar)
std::unique_ptr< ItImplAbstract > end() override
size_t size() const override
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.