/*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2015 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
template<class T, class Tag=void>
class ThreadLocal {
public:
- ThreadLocal() { }
+ ThreadLocal() = default;
T* get() const {
T* ptr = tlp_.get();
public:
ThreadLocalPtr() : id_(threadlocal_detail::StaticMeta<Tag>::create()) { }
- ThreadLocalPtr(ThreadLocalPtr&& other) : id_(other.id_) {
+ ThreadLocalPtr(ThreadLocalPtr&& other) noexcept : id_(other.id_) {
other.id_ = 0;
}
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