threadlocal_detail::StaticMeta<Tag>& meta_;
std::mutex* lock_;
- int id_;
+ uint32_t id_;
public:
class Iterator;
}
private:
- explicit Accessor(int id)
+ explicit Accessor(uint32_t id)
: meta_(threadlocal_detail::StaticMeta<Tag>::instance()),
lock_(&meta_.lock_) {
lock_->lock();
ThreadLocalPtr(const ThreadLocalPtr&) = delete;
ThreadLocalPtr& operator=(const ThreadLocalPtr&) = delete;
- int id_; // every instantiation has a unique id
+ uint32_t id_; // every instantiation has a unique id
};
} // namespace folly
return *inst_;
}
- int nextId_;
- std::vector<int> freeIds_;
+ uint32_t nextId_;
+ std::vector<uint32_t> freeIds_;
std::mutex lock_;
pthread_key_t pthreadKey_;
ThreadEntry head_;
#endif
}
- static int create() {
- int id;
+ static uint32_t create() {
+ uint32_t id;
auto & meta = instance();
std::lock_guard<std::mutex> g(meta.lock_);
if (!meta.freeIds_.empty()) {
return id;
}
- static void destroy(size_t id) {
+ static void destroy(uint32_t id) {
try {
auto & meta = instance();
// Elements in other threads that use this id.
* Reserve enough space in the ThreadEntry::elements for the item
* @id to fit in.
*/
- static void reserve(int id) {
+ static void reserve(uint32_t id) {
auto& meta = instance();
ThreadEntry* threadEntry = getThreadEntry();
size_t prevCapacity = threadEntry->elementsCapacity;
#endif
}
- static ElementWrapper& get(size_t id) {
+ static ElementWrapper& get(uint32_t id) {
ThreadEntry* threadEntry = getThreadEntry();
if (UNLIKELY(threadEntry->elementsCapacity <= id)) {
reserve(id);