41 #ifndef vtkSMPThreadLocal_h
42 #define vtkSMPThreadLocal_h
51 typedef std::vector<T> TLS;
52 typedef typename TLS::iterator TLSIter;
67 : NumInitialized(0), Exemplar(exemplar)
83 int tid = this->GetThreadID();
84 if (!this->Initialized[tid])
86 this->Internal[tid] = this->Exemplar;
87 this->Initialized[tid] =
true;
88 ++this->NumInitialized;
90 return this->Internal[tid];
98 return this->NumInitialized;
119 while(this->InitIter != this->EndIter)
140 return this->Iter == other.Iter;
145 return this->Iter != other.Iter;
160 std::vector<bool>::iterator InitIter;
161 std::vector<bool>::iterator EndIter;
170 TLSIter iter = this->Internal.begin();
171 std::vector<bool>::iterator iter2 =
172 this->Initialized.begin();
173 std::vector<bool>::iterator enditer =
174 this->Initialized.end();
177 while(iter2 != enditer)
187 retVal.InitIter = iter2;
188 retVal.EndIter = enditer;
200 retVal.InitIter = this->Initialized.end();
201 retVal.EndIter = this->Initialized.end();
202 retVal.Iter = this->Internal.end();
209 std::vector<bool> Initialized;
210 size_t NumInitialized;
215 this->Internal.resize(this->GetNumberOfThreads());
216 this->Initialized.resize(this->GetNumberOfThreads());
217 std::fill(this->Initialized.begin(),
218 this->Initialized.end(),
222 inline int GetNumberOfThreads()
227 inline int GetThreadID()
vtkSMPThreadLocal(const T &exemplar)
bool operator!=(const iterator &other)
bool operator==(const iterator &other)
A simple thread local implementation for sequential operations.