21#ifndef SequentialvtkSMPThreadLocalImpl_h
22#define SequentialvtkSMPThreadLocalImpl_h
41 typedef std::vector<T> TLS;
42 typedef typename TLS::iterator TLSIter;
61 int tid = this->GetThreadID();
62 if (!this->Initialized[tid])
64 this->Internal[tid] = this->Exemplar;
65 this->Initialized[tid] =
true;
66 ++this->NumInitialized;
68 return this->Internal[tid];
71 size_t size()
const override {
return this->NumInitialized; }
83 while (this->InitIter != this->EndIter)
96 return this->Iter ==
static_cast<ItImpl*
>(other)->Iter;
108 std::vector<bool>::iterator InitIter;
109 std::vector<bool>::iterator EndIter;
113 std::unique_ptr<ItImplAbstract>
begin() override
115 TLSIter iter = this->Internal.begin();
116 std::vector<bool>::iterator iter2 = this->Initialized.begin();
117 std::vector<bool>::iterator enditer = this->Initialized.end();
120 while (iter2 != enditer)
130 auto retVal = std::unique_ptr<ItImpl>(
new ItImpl());
131 retVal->InitIter = iter2;
132 retVal->EndIter = enditer;
135 std::unique_ptr<ItImplAbstract> abstractIt(std::move(retVal));
139 std::unique_ptr<ItImplAbstract>
end()
override
142 auto retVal = std::unique_ptr<ItImpl>(
new ItImpl());
143 retVal->InitIter = this->Initialized.end();
144 retVal->EndIter = this->Initialized.end();
145 retVal->Iter = this->Internal.end();
147 std::unique_ptr<ItImplAbstract> abstractIt(std::move(retVal));
153 std::vector<bool> Initialized;
154 size_t NumInitialized;
159 this->Internal.resize(this->GetNumberOfThreads());
160 this->Initialized.resize(this->GetNumberOfThreads());
161 std::fill(this->Initialized.begin(), this->Initialized.end(),
false);
164 inline int GetNumberOfThreads() {
return 1; }
166 inline int GetThreadID() {
return 0; }
169 vtkSMPThreadLocalImpl(
const vtkSMPThreadLocalImpl&) =
delete;
170 void operator=(
const vtkSMPThreadLocalImpl&) =
delete;
ItImpl & operator=(const ItImpl &)=default
virtual std::unique_ptr< ItImpl > begin()=0
bool Compare(ItImplAbstract *other) override
T * GetContentPtr() override
void Increment() override
T & GetContent() override
virtual ItImpl * CloneImpl() const override
vtkSMPThreadLocalImpl(const T &exemplar)
std::unique_ptr< ItImplAbstract > end() override
size_t size() const override
Specialization of tuple ranges and iterators for vtkAOSDataArrayTemplate.