2 * Copyright 2017 Facebook, Inc.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
23 #include <folly/Indestructible.h>
24 #include <folly/Synchronized.h>
25 #include <folly/ThreadLocal.h>
30 * A hook for tracking which threads belong to which thread pools.
31 * This is used only by a gdb extension to aid in debugging. You won't be able
32 * to see any useful information from within C++ code.
34 * An instance of ThreadPoolListHook should be created in the thread pool class
35 * that you want to keep track of. Then, to register a thread you call
36 * registerThread() on your instance of ThreadPoolListHook from that thread.
38 * When a thread exits it will be removed from the list
39 * When the thread pool is destroyed, it will be removed from the list
41 class ThreadPoolListHook {
44 * Name is used to identify the thread pool when listing threads.
46 explicit ThreadPoolListHook(std::string name);
47 ~ThreadPoolListHook();
50 * Call this from any new thread that the thread pool creates.
52 void registerThread();
54 ThreadPoolListHook(const ThreadPoolListHook& other) = delete;
55 ThreadPoolListHook& operator=(const ThreadPoolListHook&) = delete;