userver
C++ Async Framework
Toggle main menu visibility
Documentation
API Groups
Namespaces
Reference
Class List
Class Index
File List
Macros
All
e
i
l
r
t
u
Functions
Macros
e
i
l
r
t
u
Examples
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Pages
Concepts
Loading...
Searching...
No Matches
processor.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/os_signals/processor.hpp
4
/// @brief @copybrief os_signals::Processor
5
6
#
include
<
userver
/
concurrent
/
async_event_channel
.
hpp
>
7
#
include
<
userver
/
engine
/
task
/
task_processor_fwd
.
hpp
>
8
#
include
<
userver
/
os_signals
/
subscriber
.
hpp
>
9
#
include
<
userver
/
utils
/
impl
/
internal_tag
.
hpp
>
10
11
USERVER_NAMESPACE_BEGIN
12
13
namespace
os_signals
{
14
15
#
if
!
defined
(
__APPLE__
)
16
17
/// @brief Constant for SIGUSR1
18
inline
constexpr
int
kSigUsr1
= 10;
19
20
/// @brief Constant for SIGUSR2
21
inline
constexpr
int
kSigUsr2
= 12;
22
23
#
else
24
inline
constexpr
int
kSigUsr1
= 30;
25
inline
constexpr
int
kSigUsr2
= 31;
26
#
endif
27
28
/// @ingroup userver_clients
29
///
30
/// @brief A client that allows to subscribe
31
/// to OS signals `SIGUSR1` and `SIGUSR2`.
32
///
33
/// Usually retrieved from os_signals::ProcessorComponent. For tests
34
/// use os_signals::ProcessorMock.
35
///
36
/// @see @ref scripts/docs/en/userver/os_signals.md
37
class
Processor
final
{
38
public
:
39
explicit
Processor(engine::TaskProcessor& task_processor);
40
41
/// Listen for a specific signal `signum`. See the other overload for
42
/// subscription to both signals.
43
template
<
class
Class>
44
Subscriber
AddListener
(Class* obj, std::string_view name,
int
signum,
void
(Class::*func)()) {
45
auto
execute = [obj, func, signum](
int
sig) {
46
if
(sig == signum) {
47
(obj->*func)();
48
}
49
};
50
51
return
channel_.AddListener(
concurrent
::FunctionId(obj), name, std::move(execute));
52
}
44
Subscriber
AddListener
(Class* obj, std::string_view name,
int
signum,
void
(Class::*func)()) {
…
}
53
54
/// Listen for all the OS signals.
55
template
<
class
Class>
56
Subscriber
AddListener
(Class* obj, std::string_view name,
void
(Class::*func)(
int
/*signum*/
)) {
57
auto
execute = [obj, func](
int
sig) { (obj->*func)(sig); };
58
return
channel_.AddListener(
concurrent
::FunctionId(obj), name, std::move(execute));
59
}
56
Subscriber
AddListener
(Class* obj, std::string_view name,
void
(Class::*func)(
int
/*signum*/
)) {
…
}
60
61
/// @cond
62
// For internal use
63
void
Notify(
int
signum,
utils
::impl::InternalTag);
64
/// @endcond
65
private
:
66
concurrent
::
AsyncEventChannel
<
int
> channel_;
67
engine::TaskProcessor& task_processor_;
68
};
37
class
Processor
final
{
…
};
69
70
}
// namespace os_signals
71
72
USERVER_NAMESPACE_END
userver
os_signals
processor.hpp
Generated on Wed Apr 30 2025 15:53:30 for userver by
Doxygen
1.13.2