ThreadUtil.h 758 B

12345678910111213141516171819202122232425262728293031323334
  1. /*
  2. * Copyright (c) Meta Platforms, Inc. and affiliates.
  3. * All rights reserved.
  4. *
  5. * This source code is licensed under the BSD-style license found in the
  6. * LICENSE file in the root directory of this source tree.
  7. */
  8. #pragma once
  9. #include <cstdint>
  10. #include <string>
  11. #include <utility>
  12. #include <vector>
  13. namespace libkineto {
  14. int32_t systemThreadId();
  15. int32_t threadId();
  16. bool setThreadName(const std::string& name);
  17. std::string getThreadName();
  18. int32_t processId();
  19. std::string processName(int32_t pid);
  20. // Return a list of pids and process names for the current process
  21. // and its parents.
  22. std::vector<std::pair<int32_t, std::string>> pidCommandPairsOfAncestors();
  23. } // namespace libkineto
  24. #ifdef HAS_ROCTRACER
  25. using namespace libkineto;
  26. #endif