userver
C++ Async Framework
Toggle main menu visibility
Loading...
Searching...
No Matches
processor.hpp
Go to the documentation of this file.
1
#pragma once
2
5
6
#include <
userver/concurrent/async_event_channel.hpp
>
7
#include <
userver/engine/task/task_processor_fwd.hpp
>
8
#include <userver/utils/impl/internal_tag.hpp>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
os_signals
{
13
14
#if !defined(__APPLE__)
15
17
inline
constexpr
int
kSigUsr1
= 10;
18
20
inline
constexpr
int
kSigUsr2
= 12;
21
22
#else
23
inline
constexpr
int
kSigUsr1
= 30;
24
inline
constexpr
int
kSigUsr2
= 31;
25
#endif
26
36
class
Processor final {
37
public
:
38
explicit
Processor(engine::TaskProcessor& task_processor);
39
47
template
<
class
Class>
48
void
AddListener
(
49
utils::ResourceScopeStorage
& scopes,
50
Class* obj,
51
std::string_view name,
52
int
signum,
53
void
(Class::*func)()
54
) {
55
channel_.AddListener(scopes,
concurrent::FunctionId
(obj), name, [obj, func, signum](
int
sig) {
56
if
(sig == signum) {
57
(obj->*func)();
58
}
59
});
60
}
61
68
template
<
class
Class>
69
void
AddListener
(
utils::ResourceScopeStorage
& scopes, Class* obj, std::string_view name,
void
(Class::*func)(
int
)) {
70
channel_.AddListener(scopes, obj, name, func);
71
}
72
74
// For internal use
75
void
Notify(
int
signum, utils::impl::InternalTag);
77
private
:
78
concurrent::AsyncEventChannel<int>
channel_;
79
engine::TaskProcessor& task_processor_;
80
};
81
82
}
// namespace os_signals
83
84
USERVER_NAMESPACE_END
userver
os_signals
processor.hpp
Generated on
for userver by
Doxygen
1.17.0