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
ac2f6f23
Commit
ac2f6f23
authored
Oct 23, 2019
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
convert invoke_message_result to an enum class
parent
8607ad2f
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
111 additions
and
110 deletions
+111
-110
libcaf_core/CMakeLists.txt
libcaf_core/CMakeLists.txt
+2
-0
libcaf_core/caf/fwd.hpp
libcaf_core/caf/fwd.hpp
+1
-0
libcaf_core/caf/invoke_message_result.hpp
libcaf_core/caf/invoke_message_result.hpp
+14
-10
libcaf_core/src/raw_event_based_actor.cpp
libcaf_core/src/raw_event_based_actor.cpp
+16
-14
libcaf_core/src/scheduled_actor.cpp
libcaf_core/src/scheduled_actor.cpp
+75
-83
libcaf_io/src/io/network/manager.cpp
libcaf_io/src/io/network/manager.cpp
+3
-3
No files found.
libcaf_core/CMakeLists.txt
View file @
ac2f6f23
...
...
@@ -7,6 +7,7 @@ file(GLOB_RECURSE LIBCAF_CORE_HDRS "caf/*.hpp")
enum_to_string
(
"caf/exit_reason.hpp"
"exit_reason_strings.cpp"
)
enum_to_string
(
"caf/intrusive/inbox_result.hpp"
"inbox_result_strings.cpp"
)
enum_to_string
(
"caf/intrusive/task_result.hpp"
"task_result_strings.cpp"
)
enum_to_string
(
"caf/invoke_message_result.hpp"
"invoke_msg_result_strings.cpp"
)
enum_to_string
(
"caf/message_priority.hpp"
"message_priority_strings.cpp"
)
enum_to_string
(
"caf/pec.hpp"
"pec_strings.cpp"
)
enum_to_string
(
"caf/sec.hpp"
"sec_strings.cpp"
)
...
...
@@ -16,6 +17,7 @@ enum_to_string("caf/stream_priority.hpp" "stream_priority_strings.cpp")
set
(
LIBCAF_CORE_SRCS
"
${
CMAKE_CURRENT_BINARY_DIR
}
/exit_reason_strings.cpp"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/inbox_result_strings.cpp"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/invoke_msg_result_strings.cpp"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/message_priority_strings.cpp"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/pec_strings.cpp"
"
${
CMAKE_CURRENT_BINARY_DIR
}
/sec_strings.cpp"
...
...
libcaf_core/caf/fwd.hpp
View file @
ac2f6f23
...
...
@@ -177,6 +177,7 @@ enum class atom_value : uint64_t;
enum
class
byte
:
uint8_t
;
enum
class
sec
:
uint8_t
;
enum
class
stream_priority
;
enum
class
invoke_message_result
;
// -- aliases ------------------------------------------------------------------
...
...
libcaf_core/caf/invoke_message_result.hpp
View file @
ac2f6f23
...
...
@@ -22,17 +22,21 @@
namespace
caf
{
enum
invoke_message_result
{
im_success
,
im_skipped
,
im_dropped
/// Stores the result of a message invocation.
enum
class
invoke_message_result
{
/// Indicates that the actor consumed the message.
consumed
,
/// Indicates that the actor left the message in the mailbox.
skipped
,
/// Indicates that the actor discarded the message based on meta data. For
/// example, timeout messages for already received requests usually get
/// dropped without calling any user-defined code.
dropped
,
};
inline
std
::
string
to_string
(
invoke_message_result
x
)
{
return
x
==
im_success
?
"im_success"
:
(
x
==
im_skipped
?
"im_skipped"
:
"im_dropped"
);
}
/// @relates invoke_message_result
std
::
string
to_string
(
invoke_message_result
);
}
// namespace caf
libcaf_core/src/raw_event_based_actor.cpp
View file @
ac2f6f23
...
...
@@ -23,7 +23,7 @@
namespace
caf
{
raw_event_based_actor
::
raw_event_based_actor
(
actor_config
&
cfg
)
:
event_based_actor
(
cfg
)
{
:
event_based_actor
(
cfg
)
{
// nop
}
...
...
@@ -36,30 +36,30 @@ invoke_message_result raw_event_based_actor::consume(mailbox_element& x) {
auto
&
pr
=
awaited_responses_
.
front
();
// skip all messages until we receive the currently awaited response
if
(
x
.
mid
!=
pr
.
first
)
return
i
m_
skipped
;
return
i
nvoke_message_result
::
skipped
;
if
(
!
pr
.
second
(
x
.
content
()))
{
// try again with error if first attempt failed
auto
msg
=
make_message
(
make_error
(
sec
::
unexpected_response
,
x
.
move_content_to_message
()));
auto
msg
=
make_message
(
make_error
(
sec
::
unexpected_response
,
x
.
move_content_to_message
()));
pr
.
second
(
msg
);
}
awaited_responses_
.
pop_front
();
return
i
m_success
;
return
i
nvoke_message_result
::
consumed
;
}
// handle multiplexed responses
if
(
x
.
mid
.
is_response
())
{
auto
mrh
=
multiplexed_responses_
.
find
(
x
.
mid
);
// neither awaited nor multiplexed, probably an expired timeout
if
(
mrh
==
multiplexed_responses_
.
end
())
return
i
m_
dropped
;
return
i
nvoke_message_result
::
dropped
;
if
(
!
mrh
->
second
(
x
.
content
()))
{
// try again with error if first attempt failed
auto
msg
=
make_message
(
make_error
(
sec
::
unexpected_response
,
x
.
move_content_to_message
()));
auto
msg
=
make_message
(
make_error
(
sec
::
unexpected_response
,
x
.
move_content_to_message
()));
mrh
->
second
(
msg
);
}
multiplexed_responses_
.
erase
(
mrh
);
return
i
m_success
;
return
i
nvoke_message_result
::
consumed
;
}
auto
&
content
=
x
.
content
();
// handle timeout messages
...
...
@@ -70,12 +70,12 @@ invoke_message_result raw_event_based_actor::consume(mailbox_element& x) {
if
(
is_active_receive_timeout
(
tid
))
{
CAF_LOG_DEBUG
(
"handle timeout message"
);
if
(
bhvr_stack_
.
empty
())
return
i
m_
dropped
;
return
i
nvoke_message_result
::
dropped
;
bhvr_stack_
.
back
().
handle_timeout
();
return
i
m_success
;
return
i
nvoke_message_result
::
consumed
;
}
CAF_LOG_DEBUG
(
"dropped expired timeout message"
);
return
i
m_
dropped
;
return
i
nvoke_message_result
::
dropped
;
}
// handle everything else as ordinary message
detail
::
default_invoke_result_visitor
<
event_based_actor
>
visitor
{
this
};
...
...
@@ -103,7 +103,8 @@ invoke_message_result raw_event_based_actor::consume(mailbox_element& x) {
};
if
(
bhvr_stack_
.
empty
())
{
call_default_handler
();
return
!
skipped
?
im_success
:
im_skipped
;
return
!
skipped
?
invoke_message_result
::
consumed
:
invoke_message_result
::
skipped
;
}
auto
&
bhvr
=
bhvr_stack_
.
back
();
switch
(
bhvr
(
visitor
,
x
.
content
()))
{
...
...
@@ -115,7 +116,8 @@ invoke_message_result raw_event_based_actor::consume(mailbox_element& x) {
case
match_case
:
:
no_match
:
call_default_handler
();
}
return
!
skipped
?
im_success
:
im_skipped
;
return
!
skipped
?
invoke_message_result
::
consumed
:
invoke_message_result
::
skipped
;
// should be unreachable
CAF_CRITICAL
(
"invalid message type"
);
}
...
...
libcaf_core/src/scheduled_actor.cpp
View file @
ac2f6f23
This diff is collapsed.
Click to expand it.
libcaf_io/src/io/network/manager.cpp
View file @
ac2f6f23
...
...
@@ -60,13 +60,13 @@ void manager::detach(execution_unit*, bool invoke_disconnect_message) {
auto
mptr
=
make_mailbox_element
(
nullptr
,
make_message_id
(),
{},
detach_message
());
switch
(
raw_ptr
->
consume
(
*
mptr
))
{
case
i
m_success
:
case
i
nvoke_message_result
:
:
consumed
:
raw_ptr
->
finalize
();
break
;
case
i
m_
skipped
:
case
i
nvoke_message_result
:
:
skipped
:
raw_ptr
->
push_to_cache
(
std
::
move
(
mptr
));
break
;
case
i
m_
dropped
:
case
i
nvoke_message_result
:
:
dropped
:
CAF_LOG_INFO
(
"broker dropped disconnect message"
);
break
;
}
...
...
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