Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
Actor Framework
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
cpp-libs
Actor Framework
Commits
bbf07840
Commit
bbf07840
authored
Jun 16, 2015
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `before_shutdown` callback to `io::hook`
parent
73718b1c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
3 deletions
+30
-3
libcaf_io/caf/io/hook.hpp
libcaf_io/caf/io/hook.hpp
+7
-3
libcaf_io/caf/io/middleman.hpp
libcaf_io/caf/io/middleman.hpp
+17
-0
libcaf_io/src/hook.cpp
libcaf_io/src/hook.cpp
+4
-0
libcaf_io/src/middleman.cpp
libcaf_io/src/middleman.cpp
+2
-0
No files found.
libcaf_io/caf/io/hook.hpp
View file @
bbf07840
...
...
@@ -99,8 +99,10 @@ public:
virtual
void
invalid_message_received_cb
(
const
node_id
&
source
,
const
actor_addr
&
sender
,
actor_id
invalid_dest
,
message_id
mid
,
const
message
&
msg
);
message_id
mid
,
const
message
&
msg
);
/// Called before middleman shuts down.
virtual
void
before_shutdown_cb
();
/// All possible events for IO hooks.
enum
event_type
{
...
...
@@ -113,7 +115,8 @@ public:
new_remote_actor
,
new_connection_established
,
new_route_added
,
invalid_message_received
invalid_message_received
,
before_shutdown
};
/// Handles an event by invoking the associated callback.
...
...
@@ -148,6 +151,7 @@ private:
CAF_IO_HOOK_DISPATCH
(
new_connection_established
)
CAF_IO_HOOK_DISPATCH
(
new_route_added
)
CAF_IO_HOOK_DISPATCH
(
invalid_message_received
)
CAF_IO_HOOK_DISPATCH
(
before_shutdown
)
};
}
// namespace io
...
...
libcaf_io/caf/io/middleman.hpp
View file @
bbf07840
...
...
@@ -100,6 +100,23 @@ public:
});
}
template
<
class
F
>
void
add_shutdown_cb
(
F
fun
)
{
struct
impl
:
hook
{
impl
(
F
&&
f
)
:
fun_
(
std
::
move
(
f
))
{
// nop
}
void
before_shutdown_cb
()
override
{
fun_
();
call_next
<
hook
::
before_shutdown
>
();
}
F
fun_
;
};
add_hook
<
impl
>
(
std
::
move
(
fun
));
}
/// @cond PRIVATE
// stops the singleton
...
...
libcaf_io/src/hook.cpp
View file @
bbf07840
...
...
@@ -81,5 +81,9 @@ void hook::invalid_message_received_cb(const node_id& source,
call_next
<
invalid_message_received
>
(
source
,
sender
,
invalid_dest
,
mid
,
msg
);
}
void
hook
::
before_shutdown_cb
()
{
call_next
<
before_shutdown
>
();
}
}
// namespace io
}
// namespace caf
libcaf_io/src/middleman.cpp
View file @
bbf07840
...
...
@@ -369,6 +369,7 @@ void middleman::stop() {
CAF_LOG_TRACE
(
""
);
backend_
->
dispatch
([
=
]
{
CAF_LOG_TRACE
(
""
);
notify
<
hook
::
before_shutdown
>
();
// managers_ will be modified while we are stopping each manager,
// because each manager will call remove(...)
for
(
auto
&
kvp
:
named_brokers_
)
{
...
...
@@ -379,6 +380,7 @@ void middleman::stop() {
});
backend_supervisor_
.
reset
();
thread_
.
join
();
hooks_
.
reset
();
named_brokers_
.
clear
();
scoped_actor
self
(
true
);
self
->
monitor
(
manager_
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment