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
97dffef0
Commit
97dffef0
authored
Jun 11, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow non-const default handlers
parent
e8234af5
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
22 deletions
+37
-22
CHANGELOG.md
CHANGELOG.md
+2
-0
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+35
-22
No files found.
CHANGELOG.md
View file @
97dffef0
...
@@ -20,6 +20,8 @@ is based on [Keep a Changelog](https://keepachangelog.com).
...
@@ -20,6 +20,8 @@ is based on [Keep a Changelog](https://keepachangelog.com).
properly back off, causing high CPU load due to spinning and in some scenarios
properly back off, causing high CPU load due to spinning and in some scenarios
never recovering. This issue has been resolved by properly handling
never recovering. This issue has been resolved by properly handling
`SSL_ERROR_WANT_READ`
on the transport (#1060).
`SSL_ERROR_WANT_READ`
on the transport (#1060).
-
Scheduled actors now accept default handlers for down messages etc. with
non-const apply operator such as lambda expressions declared as
`mutable`
.
### Removed
### Removed
...
...
libcaf_core/caf/scheduled_actor.hpp
View file @
97dffef0
...
@@ -294,10 +294,12 @@ public:
...
@@ -294,10 +294,12 @@ public:
/// Sets a custom handler for unexpected messages.
/// Sets a custom handler for unexpected messages.
template
<
class
F
>
template
<
class
F
>
typename
std
::
enable_if
<
std
::
is_convertible
<
std
::
enable_if_t
<
std
::
is_invocable_r_v
<
skippable_result
,
F
,
message
&>>
F
,
std
::
function
<
skippable_result
(
message
&
)
>>::
value
>::
type
set_default_handler
(
F
fun
)
{
set_default_handler
(
F
fun
)
{
default_handler_
=
[
=
](
scheduled_actor
*
,
message
&
xs
)
{
return
fun
(
xs
);
};
using
std
::
move
;
default_handler_
=
[
fn
{
move
(
fun
)}](
scheduled_actor
*
,
message
&
xs
)
mutable
{
return
fn
(
xs
);
};
}
}
/// Sets a custom handler for error messages.
/// Sets a custom handler for error messages.
...
@@ -309,9 +311,11 @@ public:
...
@@ -309,9 +311,11 @@ public:
}
}
/// Sets a custom handler for error messages.
/// Sets a custom handler for error messages.
template
<
class
T
>
template
<
class
F
>
auto
set_error_handler
(
T
fun
)
->
decltype
(
fun
(
std
::
declval
<
error
&>
()))
{
std
::
enable_if_t
<
std
::
is_invocable_v
<
F
,
error
&>>
set_error_handler
(
F
fun
)
{
set_error_handler
([
fun
](
scheduled_actor
*
,
error
&
x
)
{
fun
(
x
);
});
error_handler_
=
[
fn
{
std
::
move
(
fun
)}](
scheduled_actor
*
,
error
&
x
)
mutable
{
fn
(
x
);
};
}
}
/// Sets a custom handler for down messages.
/// Sets a custom handler for down messages.
...
@@ -323,9 +327,12 @@ public:
...
@@ -323,9 +327,12 @@ public:
}
}
/// Sets a custom handler for down messages.
/// Sets a custom handler for down messages.
template
<
class
T
>
template
<
class
F
>
auto
set_down_handler
(
T
fun
)
->
decltype
(
fun
(
std
::
declval
<
down_msg
&>
()))
{
std
::
enable_if_t
<
std
::
is_invocable_v
<
F
,
down_msg
&>>
set_down_handler
(
F
fun
)
{
set_down_handler
([
fun
](
scheduled_actor
*
,
down_msg
&
x
)
{
fun
(
x
);
});
using
std
::
move
;
down_handler_
=
[
fn
{
move
(
fun
)}](
scheduled_actor
*
,
down_msg
&
x
)
mutable
{
fn
(
x
);
};
}
}
/// Sets a custom handler for node down messages.
/// Sets a custom handler for node down messages.
...
@@ -337,11 +344,13 @@ public:
...
@@ -337,11 +344,13 @@ public:
}
}
/// Sets a custom handler for down messages.
/// Sets a custom handler for down messages.
template
<
class
T
>
template
<
class
F
>
auto
set_node_down_handler
(
T
fun
)
std
::
enable_if_t
<
std
::
is_invocable_v
<
F
,
node_down_msg
&>>
->
decltype
(
fun
(
std
::
declval
<
node_down_msg
&>
()))
{
set_node_down_handler
(
F
fun
)
{
set_node_down_handler
(
node_down_handler_
=
[
fn
{
std
::
move
(
fun
)}](
scheduled_actor
*
,
[
fun
](
scheduled_actor
*
,
node_down_msg
&
x
)
{
fun
(
x
);
});
node_down_msg
&
x
)
mutable
{
fn
(
x
);
};
}
}
/// Sets a custom handler for error messages.
/// Sets a custom handler for error messages.
...
@@ -353,9 +362,12 @@ public:
...
@@ -353,9 +362,12 @@ public:
}
}
/// Sets a custom handler for exit messages.
/// Sets a custom handler for exit messages.
template
<
class
T
>
template
<
class
F
>
auto
set_exit_handler
(
T
fun
)
->
decltype
(
fun
(
std
::
declval
<
exit_msg
&>
()))
{
std
::
enable_if_t
<
std
::
is_invocable_v
<
F
,
exit_msg
&>>
set_exit_handler
(
F
fun
)
{
set_exit_handler
([
fun
](
scheduled_actor
*
,
exit_msg
&
x
)
{
fun
(
x
);
});
using
std
::
move
;
exit_handler_
=
[
fn
{
move
(
fun
)}](
scheduled_actor
*
,
exit_msg
&
x
)
mutable
{
fn
(
x
);
};
}
}
#ifdef CAF_ENABLE_EXCEPTIONS
#ifdef CAF_ENABLE_EXCEPTIONS
...
@@ -371,11 +383,12 @@ public:
...
@@ -371,11 +383,12 @@ public:
/// Sets a custom exception handler for this actor. If multiple handlers are
/// Sets a custom exception handler for this actor. If multiple handlers are
/// defined, only the functor that was added *last* is being executed.
/// defined, only the functor that was added *last* is being executed.
template
<
class
F
>
template
<
class
F
>
typename
std
::
enable_if
<
std
::
is_convertible
<
std
::
enable_if_t
<
std
::
is_invocable_r_v
<
error
,
F
,
std
::
exception_ptr
&>>
F
,
std
::
function
<
error
(
std
::
exception_ptr
&
)
>>::
value
>::
type
set_exception_handler
(
F
fun
)
{
set_exception_handler
(
F
f
)
{
exception_handler_
=
[
fn
{
std
::
move
(
fun
)}](
scheduled_actor
*
,
set_exception_handler
(
std
::
exception_ptr
&
x
)
mutable
{
[
f
](
scheduled_actor
*
,
std
::
exception_ptr
&
x
)
{
return
f
(
x
);
});
return
fn
(
x
);
};
}
}
#endif // CAF_ENABLE_EXCEPTIONS
#endif // CAF_ENABLE_EXCEPTIONS
...
...
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