MCPcopy Create free account
hub / github.com/apache/incubator-pegasus / task_code

Class task_code

src/runtime/task/task_code.h:98–148  ·  view source on GitHub ↗

task code is an index for a specific kind of task. with the index, you can get properties of this kind of task: name, type, priority, etc. you may want to refer to task_spec.h for the detailed task properties. Like dsn::blob, task_code is a special thrift primitive type that's defined by the rDSN framework. Internally as a C++ object, it's is represented as an integer, but in thrift representatio

Source from the content-addressed store, hash-verified

96/// ✓: 1: dsn.task_code task_code;
97///
98class task_code
99{
100public:
101 constexpr task_code() = default;
102
103 constexpr explicit task_code(int code) : _internal_code(code) {}
104
105 task_code(const char *name,
106 dsn_task_type_t tt,
107 dsn_task_priority_t pri,
108 dsn::threadpool_code pool);
109
110 task_code(const char *name,
111 dsn_task_type_t tt,
112 dsn_task_priority_t pri,
113 dsn::threadpool_code pool,
114 bool is_storage_write,
115 bool allow_batch,
116 bool is_idempotent);
117
118 const char *to_string() const;
119
120 constexpr bool operator==(const task_code &r) const
121 {
122 return _internal_code == r._internal_code;
123 }
124
125 constexpr bool operator!=(const task_code &r) const { return !(*this == r); }
126
127 constexpr operator int() const { return _internal_code; }
128
129 constexpr int code() const { return _internal_code; }
130
131 // for serialization in thrift format
132 uint32_t read(::apache::thrift::protocol::TProtocol *iprot);
133 uint32_t write(::apache::thrift::protocol::TProtocol *oprot) const;
134
135 static int max();
136 static bool is_exist(const char *name);
137 static task_code try_get(const char *name, task_code default_value);
138 static task_code try_get(const std::string &name, task_code default_value);
139
140 friend std::ostream &operator<<(std::ostream &os, const task_code &tc)
141 {
142 return os << tc.to_string();
143 }
144
145private:
146 task_code(const char *name);
147 int _internal_code{0};
148};
149
150// you can define task_code by the following macros
151#define DEFINE_NAMED_TASK_CODE(x, name, pri, pool) \

Callers 15

initMethod · 0.70
register_commandsMethod · 0.70
try_getMethod · 0.70
is_enable_traceFunction · 0.50
dump_trace_pointsMethod · 0.50
mlog_dumpFunction · 0.50
worker_set_leaderFunction · 0.50
clearFunction · 0.50
TEST_FFunction · 0.50
installMethod · 0.50
installMethod · 0.50

Calls 1

to_stringMethod · 0.45

Tested by 6

initMethod · 0.56
worker_set_leaderFunction · 0.40
clearFunction · 0.40
TEST_FFunction · 0.40
TESTFunction · 0.40
TESTFunction · 0.40