aboutsummaryrefslogtreecommitdiffstats
path: root/library/cpp/actors/core/hfunc.h
blob: a8e439e93829c28964f240ab86ca546adfcfb7b0 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#pragma once

#include "actor.h"
#include "executor_thread.h"

#include <util/system/defaults.h>

#define HFunc(TEvType, HandleFunc)                                                  \
    case TEvType::EventType: {                                                      \
        typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
        HandleFunc(*x, ctx);                                                        \
        break;                                                                      \
    }

#define hFunc(TEvType, HandleFunc)                                                  \
    case TEvType::EventType: {                                                      \
        typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
        HandleFunc(*x);                                                             \
        break;                                                                      \
    }

#define HFuncTraced(TEvType, HandleFunc)                          \
    case TEvType::EventType: {                                    \
        TRACE_EVENT_TYPE(Y_STRINGIZE(TEvType));                      \
        TEvType::TPtr* x = reinterpret_cast<TEvType::TPtr*>(&ev); \
        HandleFunc(*x, ctx);                                      \
        break;                                                    \
    }

#define hFuncTraced(TEvType, HandleFunc)                                            \
    case TEvType::EventType: {                                                      \
        TRACE_EVENT_TYPE(Y_STRINGIZE(TEvType));                                        \
        typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
        HandleFunc(*x);                                                             \
        break;                                                                      \
    }

#define HTemplFunc(TEvType, HandleFunc)                                             \
    case TEvType::EventType: {                                                      \
        typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
        HandleFunc(*x, ctx);                                                        \
        break;                                                                      \
    }

#define hTemplFunc(TEvType, HandleFunc)                                             \
    case TEvType::EventType: {                                                      \
        typename TEvType::TPtr* x = reinterpret_cast<typename TEvType::TPtr*>(&ev); \
        HandleFunc(*x);                                                             \
        break;                                                                      \
    }

#define SFunc(TEvType, HandleFunc) \
    case TEvType::EventType:       \
        HandleFunc(ctx);           \
        break;

#define sFunc(TEvType, HandleFunc) \
    case TEvType::EventType:       \
        HandleFunc();              \
        break;

#define CFunc(TEventType, HandleFunc) \
    case TEventType:                  \
        HandleFunc(ctx);              \
        break;

#define cFunc(TEventType, HandleFunc) \
    case TEventType:                  \
        HandleFunc();                 \
        break;

#define FFunc(TEventType, HandleFunc) \
    case TEventType:                  \
        HandleFunc(ev, ctx);          \
        break;

#define fFunc(TEventType, HandleFunc) \
    case TEventType:                  \
        HandleFunc(ev);               \
        break;

#define IgnoreFunc(TEvType)  \
    case TEvType::EventType: \
        break;

#define ExceptionFunc(ExceptionType, HandleFunc)    \
    catch (const ExceptionType& exception) {        \
        HandleFunc(exception);                      \
    }

#define ExceptionFuncEv(ExceptionType, HandleFunc)    \
    catch (const ExceptionType& exception) {          \
        HandleFunc(exception, ev);                    \
    }

#define AnyExceptionFunc(HandleFunc)                \
    catch (...) {                                   \
        HandleFunc();                               \
    }

#define AnyExceptionFuncEv(HandleFunc)                \
    catch (...) {                                     \
        HandleFunc(ev);                               \
    }