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
41df839f
Unverified
Commit
41df839f
authored
Oct 12, 2019
by
Dominik Charousset
Committed by
GitHub
Oct 12, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #930
Use fold expression in the data_processor if available
parents
d6ebaac3
193c39fb
Changes
6
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
151 additions
and
181 deletions
+151
-181
libcaf_core/caf/data_processor.hpp
libcaf_core/caf/data_processor.hpp
+39
-0
libcaf_core/caf/meta/load_callback.hpp
libcaf_core/caf/meta/load_callback.hpp
+8
-0
libcaf_core/caf/meta/save_callback.hpp
libcaf_core/caf/meta/save_callback.hpp
+8
-0
libcaf_core/test/optional.cpp
libcaf_core/test/optional.cpp
+0
-1
libcaf_core/test/typed_spawn.cpp
libcaf_core/test/typed_spawn.cpp
+81
-164
libcaf_io/test/io/basp_broker.cpp
libcaf_io/test/io/basp_broker.cpp
+15
-16
No files found.
libcaf_core/caf/data_processor.hpp
View file @
41df839f
...
...
@@ -475,6 +475,43 @@ public:
return
none
;
}
#if defined(__cpp_fold_expressions) && defined(__cpp_if_constexpr)
template
<
class
...
Ts
>
error
operator
()(
Ts
&&
...
xs
)
{
error
result
;
auto
f
=
[
&
result
,
this
](
auto
&&
x
)
{
using
type
=
detail
::
decay_t
<
decltype
(
x
)
>
;
if
constexpr
(
meta
::
is_save_callback
<
type
>::
value
)
{
if
constexpr
(
Derived
::
reads_state
)
if
(
auto
err
=
x
.
fun
())
{
result
=
std
::
move
(
err
);
return
false
;
}
}
else
if
constexpr
(
meta
::
is_load_callback
<
type
>::
value
)
{
if
constexpr
(
Derived
::
writes_state
)
if
(
auto
err
=
x
.
fun
())
{
result
=
std
::
move
(
err
);
return
false
;
}
}
else
if
constexpr
(
meta
::
is_annotation
<
type
>::
value
||
is_allowed_unsafe_message_type
<
type
>::
value
)
{
// skip element
}
else
{
if
(
auto
err
=
dref
().
apply
(
deconst
(
x
)))
{
result
=
std
::
move
(
err
);
return
false
;
}
}
return
true
;
};
if
((
f
(
std
::
forward
<
Ts
>
(
xs
))
&&
...))
return
none
;
return
result
;
}
#else // defined(__cpp_fold_expressions) && defined(__cpp_if_constexpr)
template
<
class
F
,
class
...
Ts
>
error
operator
()(
meta
::
save_callback_t
<
F
>
x
,
Ts
&&
...
xs
)
{
// TODO: use `if constexpr` when switching to C++17.
...
...
@@ -525,6 +562,8 @@ public:
return
dref
()(
std
::
forward
<
Ts
>
(
xs
)...);
}
#endif // defined(__cpp_fold_expressions) && defined(__cpp_if_constexpr)
protected
:
virtual
error
apply_impl
(
int8_t
&
)
=
0
;
...
...
libcaf_core/caf/meta/load_callback.hpp
View file @
41df839f
...
...
@@ -18,6 +18,8 @@
#pragma once
#include <type_traits>
#include "caf/meta/annotation.hpp"
namespace
caf
{
...
...
@@ -36,6 +38,12 @@ struct load_callback_t : annotation {
F
fun
;
};
template
<
class
T
>
struct
is_load_callback
:
std
::
false_type
{};
template
<
class
F
>
struct
is_load_callback
<
load_callback_t
<
F
>>
:
std
::
true_type
{};
/// Returns an annotation that allows inspectors to call
/// user-defined code after performing load operations.
template
<
class
F
>
...
...
libcaf_core/caf/meta/save_callback.hpp
View file @
41df839f
...
...
@@ -18,6 +18,8 @@
#pragma once
#include <type_traits>
#include "caf/meta/annotation.hpp"
namespace
caf
{
...
...
@@ -36,6 +38,12 @@ struct save_callback_t : annotation {
F
fun
;
};
template
<
class
T
>
struct
is_save_callback
:
std
::
false_type
{};
template
<
class
F
>
struct
is_save_callback
<
save_callback_t
<
F
>>
:
std
::
true_type
{};
/// Returns an annotation that allows inspectors to call
/// user-defined code after performing save operations.
template
<
class
F
>
...
...
libcaf_core/test/optional.cpp
View file @
41df839f
...
...
@@ -23,7 +23,6 @@
#include "caf/optional.hpp"
using
namespace
std
;
using
namespace
caf
;
namespace
{
...
...
libcaf_core/test/typed_spawn.cpp
View file @
41df839f
This diff is collapsed.
Click to expand it.
libcaf_io/test/io/basp_broker.cpp
View file @
41df839f
...
...
@@ -33,6 +33,14 @@
#include "caf/all.hpp"
#include "caf/io/all.hpp"
#include "caf/deep_to_string.hpp"
#include "caf/io/network/interfaces.hpp"
#include "caf/io/network/test_multiplexer.hpp"
using
namespace
caf
;
using
namespace
caf
::
io
;
namespace
{
using
caf
::
make_message_id
;
...
...
@@ -72,14 +80,6 @@ constexpr auto basp_atom = caf::atom("BASP");
constexpr
auto
spawn_serv_atom
=
caf
::
atom
(
"SpawnServ"
);
constexpr
auto
config_serv_atom
=
caf
::
atom
(
"ConfigServ"
);
}
// namespace
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
::
io
;
namespace
{
constexpr
uint32_t
num_remote_nodes
=
2
;
using
buffer
=
std
::
vector
<
char
>
;
...
...
@@ -259,10 +259,9 @@ public:
return
{
hdr
,
std
::
move
(
payload
)};
}
void
connect_node
(
node
&
n
,
optional
<
accept_handle
>
ax
=
none
,
void
connect_node
(
node
&
n
,
optional
<
accept_handle
>
ax
=
none
,
actor_id
published_actor_id
=
invalid_actor_id
,
const
set
<
string
>&
published_actor_ifs
=
std
::
set
<
std
::
string
>
{})
{
const
std
::
set
<
std
::
string
>&
published_actor_ifs
=
{})
{
auto
src
=
ax
?
*
ax
:
ahdl_
;
CAF_MESSAGE
(
"connect remote node "
<<
n
.
name
<<
", connection ID = "
<<
n
.
connection
.
id
()
...
...
@@ -412,8 +411,8 @@ private:
accept_handle
ahdl_
;
network
::
test_multiplexer
*
mpx_
;
node_id
this_node_
;
unique_ptr
<
scoped_actor
>
self_
;
array
<
node
,
num_remote_nodes
>
nodes_
;
std
::
unique_ptr
<
scoped_actor
>
self_
;
std
::
array
<
node
,
num_remote_nodes
>
nodes_
;
/*
array<node_id, num_remote_nodes> remote_node_;
array<connection_handle, num_remote_nodes> remote_hdl_;
...
...
@@ -493,7 +492,7 @@ CAF_TEST(non_empty_server_handshake) {
buffer
expected_payload
;
binary_serializer
bd
{
nullptr
,
expected_payload
};
bd
(
instance
().
this_node
(),
defaults
::
middleman
::
app_identifiers
,
self
()
->
id
(),
s
et
<
string
>
{
"caf::replies_to<@u16>::with<@u16>"
});
s
td
::
set
<
std
::
string
>
{
"caf::replies_to<@u16>::with<@u16>"
});
CAF_CHECK_EQUAL
(
hexstr
(
payload
),
hexstr
(
expected_payload
));
}
...
...
@@ -633,7 +632,7 @@ CAF_TEST(remote_actor_and_send) {
{
basp
::
message_type
::
direct_message
,
0
,
0
,
0
,
jupiter
().
dummy_actor
->
id
(),
self
()
->
id
()},
std
::
vector
<
strong_actor_ptr
>
{},
make_message
(
"hi there!"
));
self
()
->
receive
([
&
](
const
string
&
str
)
{
self
()
->
receive
([
&
](
const
st
d
::
st
ring
&
str
)
{
CAF_CHECK_EQUAL
(
to_string
(
self
()
->
current_sender
()),
to_string
(
result
));
CAF_CHECK_EQUAL
(
self
()
->
current_sender
(),
result
.
address
());
CAF_CHECK_EQUAL
(
str
,
"hi there!"
);
...
...
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