1// Copyright (c) Microsoft Corporation. All rights reserved.
2// Licensed under the MIT license.
3
4#include "thread.h"
5
6namespace FASTER {
7namespace core {
8
9/// The first thread will have index 0.
10std::atomic<uint32_t> Thread::next_index_{ 0 };
11
12/// No thread IDs have been used yet.
13std::atomic<bool> Thread::id_used_[kMaxNumThreads] = {};
14
15#ifdef COUNT_ACTIVE_THREADS
16std::atomic<int32_t> Thread::current_num_threads_ { 0 };
17#endif
18
19/// Give the new thread an ID. (In this implementation, threads get IDs when they are created, and
20/// release them when they are freed. We will eventually merge chkulk's improvements, from another
21/// branch, and then threads will get IDs on their first call to FasterKv::StartSession(), while
22/// still releasing IDs when they are freed.)
23thread_local Thread::ThreadId Thread::id_{};
24
25}
26} // namespace FASTER::core
27