what_thread_does.h 657 B

12345678910111213141516171819202122232425262728
  1. #pragma once
  2. const char* PushWhatThreadDoes(const char* what);
  3. void PopWhatThreadDoes(const char* prev);
  4. const char** WhatThreadDoesLocation();
  5. struct TWhatThreadDoesPushPop {
  6. private:
  7. const char* Prev;
  8. public:
  9. TWhatThreadDoesPushPop(const char* what) {
  10. Prev = PushWhatThreadDoes(what);
  11. }
  12. ~TWhatThreadDoesPushPop() {
  13. PopWhatThreadDoes(Prev);
  14. }
  15. };
  16. #ifdef __GNUC__
  17. #define WHAT_THREAD_DOES_FUNCTION __PRETTY_FUNCTION__
  18. #else
  19. #define WHAT_THREAD_DOES_FUNCTION __FUNCTION__
  20. #endif
  21. #define WHAT_THREAD_DOES_PUSH_POP_CURRENT_FUNC() \
  22. TWhatThreadDoesPushPop whatThreadDoesPushPopCurrentFunc(WHAT_THREAD_DOES_FUNCTION)