hfunc.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. #pragma once
  2. #include "actor.h"
  3. #include "executor_thread.h"
  4. #include <util/system/defaults.h>
  5. #define HFuncCtx(TEvType, HandleFunc, Ctx) \
  6. case TEvType::EventType: { \
  7. typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
  8. HandleFunc(*x, Ctx); \
  9. break; \
  10. }
  11. #define HFunc(TEvType, HandleFunc) \
  12. case TEvType::EventType: { \
  13. typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
  14. HandleFunc(*x, this->ActorContext()); \
  15. break; \
  16. }
  17. #define hFunc(TEvType, HandleFunc) \
  18. case TEvType::EventType: { \
  19. typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
  20. HandleFunc(*x); \
  21. break; \
  22. }
  23. #define HFuncTraced(TEvType, HandleFunc) \
  24. case TEvType::EventType: { \
  25. TRACE_EVENT_TYPE(Y_STRINGIZE(TEvType)); \
  26. TEvType::TPtr* x = reinterpret_cast<TEvType::TPtr*>(&ev); \
  27. HandleFunc(*x, this->ActorContext()); \
  28. break; \
  29. }
  30. #define hFuncTraced(TEvType, HandleFunc) \
  31. case TEvType::EventType: { \
  32. TRACE_EVENT_TYPE(Y_STRINGIZE(TEvType)); \
  33. typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
  34. HandleFunc(*x); \
  35. break; \
  36. }
  37. #define HTemplFunc(TEvType, HandleFunc) \
  38. case TEvType::EventType: { \
  39. typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
  40. HandleFunc(*x, this->ActorContext()); \
  41. break; \
  42. }
  43. #define hTemplFunc(TEvType, HandleFunc) \
  44. case TEvType::EventType: { \
  45. typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
  46. HandleFunc(*x); \
  47. break; \
  48. }
  49. #define SFunc(TEvType, HandleFunc) \
  50. case TEvType::EventType: \
  51. HandleFunc(this->ActorContext()); \
  52. break;
  53. #define sFunc(TEvType, HandleFunc) \
  54. case TEvType::EventType: \
  55. HandleFunc(); \
  56. break;
  57. #define CFunc(TEventType, HandleFunc) \
  58. case TEventType: \
  59. HandleFunc(this->ActorContext()); \
  60. break;
  61. #define CFuncCtx(TEventType, HandleFunc, ctx) \
  62. case TEventType: \
  63. HandleFunc(ctx); \
  64. break;
  65. #define cFunc(TEventType, HandleFunc) \
  66. case TEventType: \
  67. HandleFunc(); \
  68. break;
  69. #define FFunc(TEventType, HandleFunc) \
  70. case TEventType: \
  71. HandleFunc(ev, this->ActorContext()); \
  72. break;
  73. #define fFunc(TEventType, HandleFunc) \
  74. case TEventType: \
  75. HandleFunc(ev); \
  76. break;
  77. #define IgnoreFunc(TEvType) \
  78. case TEvType::EventType: \
  79. break;
  80. #define ExceptionFunc(ExceptionType, HandleFunc) \
  81. catch (const ExceptionType& exception) { \
  82. HandleFunc(exception); \
  83. }
  84. #define ExceptionFuncEv(ExceptionType, HandleFunc) \
  85. catch (const ExceptionType& exception) { \
  86. HandleFunc(exception, ev); \
  87. }
  88. #define AnyExceptionFunc(HandleFunc) \
  89. catch (...) { \
  90. HandleFunc(); \
  91. }
  92. #define AnyExceptionFuncEv(HandleFunc) \
  93. catch (...) { \
  94. HandleFunc(ev); \
  95. }