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
89cee7a7
Commit
89cee7a7
authored
Apr 20, 2022
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Deprecate replies_to and reacts_to
parent
35aea2c1
Changes
28
Show whitespace changes
Inline
Side-by-side
Showing
28 changed files
with
95 additions
and
104 deletions
+95
-104
CHANGELOG.md
CHANGELOG.md
+5
-0
libcaf_core/caf/check_typed_input.hpp
libcaf_core/caf/check_typed_input.hpp
+1
-3
libcaf_core/caf/composed_type.hpp
libcaf_core/caf/composed_type.hpp
+0
-1
libcaf_core/caf/deduce_mpi.hpp
libcaf_core/caf/deduce_mpi.hpp
+0
-1
libcaf_core/caf/detail/typed_actor_util.hpp
libcaf_core/caf/detail/typed_actor_util.hpp
+0
-1
libcaf_core/caf/interface_mismatch.hpp
libcaf_core/caf/interface_mismatch.hpp
+1
-3
libcaf_core/caf/replies_to.hpp
libcaf_core/caf/replies_to.hpp
+5
-2
libcaf_core/caf/response_type.hpp
libcaf_core/caf/response_type.hpp
+0
-1
libcaf_core/caf/typed_actor.hpp
libcaf_core/caf/typed_actor.hpp
+0
-1
libcaf_core/caf/typed_behavior.hpp
libcaf_core/caf/typed_behavior.hpp
+2
-2
libcaf_core/caf/typed_event_based_actor.hpp
libcaf_core/caf/typed_event_based_actor.hpp
+4
-6
libcaf_core/src/replies_to.cpp
libcaf_core/src/replies_to.cpp
+0
-1
libcaf_core/test/core-test.hpp
libcaf_core/test/core-test.hpp
+5
-4
libcaf_core/test/decorator/sequencer.cpp
libcaf_core/test/decorator/sequencer.cpp
+2
-2
libcaf_core/test/dynamic_spawn.cpp
libcaf_core/test/dynamic_spawn.cpp
+1
-1
libcaf_core/test/function_view.cpp
libcaf_core/test/function_view.cpp
+3
-4
libcaf_core/test/handles.cpp
libcaf_core/test/handles.cpp
+2
-2
libcaf_core/test/metaprogramming.cpp
libcaf_core/test/metaprogramming.cpp
+11
-10
libcaf_core/test/mixin/requester.cpp
libcaf_core/test/mixin/requester.cpp
+13
-12
libcaf_core/test/simple_timeout.cpp
libcaf_core/test/simple_timeout.cpp
+1
-1
libcaf_core/test/typed_behavior.cpp
libcaf_core/test/typed_behavior.cpp
+2
-3
libcaf_core/test/typed_spawn.cpp
libcaf_core/test/typed_spawn.cpp
+8
-15
libcaf_io/caf/io/middleman_actor.hpp
libcaf_io/caf/io/middleman_actor.hpp
+12
-12
libcaf_io/caf/io/typed_broker.hpp
libcaf_io/caf/io/typed_broker.hpp
+4
-4
libcaf_io/test/io-test.hpp
libcaf_io/test/io-test.hpp
+3
-3
libcaf_io/test/io/broker.cpp
libcaf_io/test/io/broker.cpp
+1
-1
libcaf_io/test/io/remote_actor.cpp
libcaf_io/test/io/remote_actor.cpp
+1
-1
manual/Actors.rst
manual/Actors.rst
+8
-7
No files found.
CHANGELOG.md
View file @
89cee7a7
...
...
@@ -12,6 +12,11 @@ is based on [Keep a Changelog](https://keepachangelog.com).
destructor of the promise now checks for this case.
-
Accessing URI fields now always returns the normalized string.
### Deprecated
-
The obsolete meta-programming utilities
`replies_to`
and
`reacts_to`
no longer
serve any purpose and are thus deprecated.
## [0.18.6]
### Added
...
...
libcaf_core/caf/check_typed_input.hpp
View file @
89cee7a7
...
...
@@ -4,10 +4,8 @@
#pragma once
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
namespace
caf
{
...
...
libcaf_core/caf/composed_type.hpp
View file @
89cee7a7
...
...
@@ -6,7 +6,6 @@
#include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace
caf
{
...
...
libcaf_core/caf/deduce_mpi.hpp
View file @
89cee7a7
...
...
@@ -9,7 +9,6 @@
#include "caf/detail/implicit_conversions.hpp"
#include "caf/expected.hpp"
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace
caf
::
detail
{
...
...
libcaf_core/caf/detail/typed_actor_util.hpp
View file @
89cee7a7
...
...
@@ -8,7 +8,6 @@
#include "caf/delegated.hpp"
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/response_promise.hpp"
#include "caf/system_messages.hpp"
#include "caf/typed_response_promise.hpp"
...
...
libcaf_core/caf/interface_mismatch.hpp
View file @
89cee7a7
...
...
@@ -4,10 +4,8 @@
#pragma once
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
#include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
namespace
caf
::
detail
{
...
...
libcaf_core/caf/replies_to.hpp
View file @
89cee7a7
...
...
@@ -17,12 +17,15 @@ replies_to_type_name(size_t input_size, const std::string* input,
size_t
output_size
,
const
std
::
string
*
output
);
template
<
class
...
Is
>
struct
replies_to
{
struct
[[
deprecated
(
"write 'result<foo>(bar)' instead of "
"'replies_to<bar>::with<foo>'"
)]]
replies_to
{
template
<
class
...
Os
>
using
with
=
result
<
Os
...
>
(
Is
...);
};
template
<
class
...
Is
>
using
reacts_to
=
result
<
void
>
(
Is
...);
using
reacts_to
[[
deprecated
(
"write 'result<void>(foo)' instead of 'reacts_to<foo>'"
)]]
=
result
<
void
>
(
Is
...);
}
// namespace caf
libcaf_core/caf/response_type.hpp
View file @
89cee7a7
...
...
@@ -8,7 +8,6 @@
#include "caf/detail/type_list.hpp"
#include "caf/fwd.hpp"
#include "caf/replies_to.hpp"
namespace
caf
{
...
...
libcaf_core/caf/typed_actor.hpp
View file @
89cee7a7
...
...
@@ -15,7 +15,6 @@
#include "caf/fwd.hpp"
#include "caf/intrusive_ptr.hpp"
#include "caf/make_actor.hpp"
#include "caf/replies_to.hpp"
#include "caf/stateful_actor.hpp"
#include "caf/type_id_list.hpp"
#include "caf/typed_actor_view_base.hpp"
...
...
libcaf_core/caf/typed_behavior.hpp
View file @
89cee7a7
...
...
@@ -77,10 +77,10 @@ template <class T>
struct
is_system_msg_handler
:
std
::
false_type
{};
template
<
>
struct
is_system_msg_handler
<
reacts_to
<
exit_msg
>
>
:
std
::
true_type
{};
struct
is_system_msg_handler
<
void
(
exit_msg
)
>
:
std
::
true_type
{};
template
<
>
struct
is_system_msg_handler
<
reacts_to
<
down_msg
>
>
:
std
::
true_type
{};
struct
is_system_msg_handler
<
void
(
down_msg
)
>
:
std
::
true_type
{};
// Tests whether the input list (IList) matches the
// signature list (SList) for a typed actor behavior
...
...
libcaf_core/caf/typed_event_based_actor.hpp
View file @
89cee7a7
...
...
@@ -4,15 +4,13 @@
#pragma once
#include "caf/
replies_to
.hpp"
#include "caf/
actor_system
.hpp"
#include "caf/local_actor.hpp"
#include "caf/mixin/behavior_changer.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/typed_actor.hpp"
#include "caf/actor_system.hpp"
#include "caf/typed_behavior.hpp"
#include "caf/scheduled_actor.hpp"
#include "caf/mixin/requester.hpp"
#include "caf/mixin/behavior_changer.hpp"
namespace
caf
{
...
...
libcaf_core/src/replies_to.cpp
View file @
89cee7a7
...
...
@@ -2,7 +2,6 @@
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#include "caf/replies_to.hpp"
#include "caf/string_algorithms.hpp"
namespace
caf
{
...
...
libcaf_core/test/core-test.hpp
View file @
89cee7a7
#include "caf/fwd.hpp"
#include "caf/result.hpp"
#include "caf/test/bdd_dsl.hpp"
#include "caf/type_id.hpp"
#include "caf/typed_actor.hpp"
...
...
@@ -10,13 +11,13 @@
// -- forward declarations for all unit test suites ----------------------------
using
float_actor
=
caf
::
typed_actor
<
caf
::
re
acts_to
<
float
>
>
;
using
float_actor
=
caf
::
typed_actor
<
caf
::
re
sult
<
void
>
(
float
)
>
;
using
int_actor
=
caf
::
typed_actor
<
caf
::
re
plies_to
<
int32_t
>::
with
<
int32_t
>
>
;
using
int_actor
=
caf
::
typed_actor
<
caf
::
re
sult
<
int32_t
>
(
int32_t
)
>
;
using
foo_actor
=
caf
::
typed_actor
<
caf
::
re
plies_to
<
int32_t
,
int32_t
,
int32_t
>::
with
<
int32_t
>
,
caf
::
re
plies_to
<
double
>::
with
<
double
,
double
>
>
;
=
caf
::
typed_actor
<
caf
::
re
sult
<
int32_t
>
(
int32_t
,
int32_t
,
int32_t
)
,
caf
::
re
sult
<
double
,
double
>
(
double
)
>
;
// A simple POD type.
struct
dummy_struct
{
...
...
libcaf_core/test/decorator/sequencer.cpp
View file @
89cee7a7
...
...
@@ -23,8 +23,8 @@ behavior testee(event_based_actor* self) {
};
}
using
first_stage
=
typed_actor
<
re
plies_to
<
int
>::
with
<
double
,
double
>
>
;
using
second_stage
=
typed_actor
<
re
plies_to
<
double
,
double
>::
with
<
double
>
>
;
using
first_stage
=
typed_actor
<
re
sult
<
double
,
double
>
(
int
)
>
;
using
second_stage
=
typed_actor
<
re
sult
<
double
>
(
double
,
double
)
>
;
first_stage
::
behavior_type
typed_first_stage
()
{
return
{
...
...
libcaf_core/test/dynamic_spawn.cpp
View file @
89cee7a7
...
...
@@ -367,7 +367,7 @@ CAF_TEST(function_spawn) {
self
->
send_exit
(
a2
,
exit_reason
::
user_shutdown
);
}
using
typed_testee
=
typed_actor
<
re
plies_to
<
abc_atom
>::
with
<
std
::
string
>
>
;
using
typed_testee
=
typed_actor
<
re
sult
<
std
::
string
>
(
abc_atom
)
>
;
typed_testee
::
behavior_type
testee
()
{
return
{[](
abc_atom
)
{
...
...
libcaf_core/test/function_view.cpp
View file @
89cee7a7
...
...
@@ -15,7 +15,7 @@ using namespace caf;
namespace
{
using
calculator
=
typed_actor
<
re
plies_to
<
int
,
int
>::
with
<
int
>
>
;
using
calculator
=
typed_actor
<
re
sult
<
int
>
(
int
,
int
)
>
;
calculator
::
behavior_type
adder
()
{
return
{
...
...
@@ -39,7 +39,7 @@ calculator::behavior_type divider() {
};
}
using
doubler
=
typed_actor
<
re
plies_to
<
int
>::
with
<
int
,
int
>
>
;
using
doubler
=
typed_actor
<
re
sult
<
int
,
int
>
(
int
)
>
;
doubler
::
behavior_type
simple_doubler
()
{
return
{
...
...
@@ -49,8 +49,7 @@ doubler::behavior_type simple_doubler() {
};
}
using
cell
=
typed_actor
<
reacts_to
<
put_atom
,
int
>
,
replies_to
<
get_atom
>::
with
<
int
>>
;
using
cell
=
typed_actor
<
result
<
void
>
(
put_atom
,
int
),
result
<
int
>
(
get_atom
)
>
;
struct
cell_state
{
int
value
=
0
;
...
...
libcaf_core/test/handles.cpp
View file @
89cee7a7
...
...
@@ -17,8 +17,8 @@ using namespace caf;
namespace
{
// Simple int32
_
terface for testee actors.
using
testee_actor
=
typed_actor
<
re
plies_to
<
int32_t
>::
with
<
int32_t
>
>
;
// Simple int32
in
terface for testee actors.
using
testee_actor
=
typed_actor
<
re
sult
<
int32_t
>
(
int32_t
)
>
;
// Dynamically typed testee.
behavior
dt_testee
()
{
...
...
libcaf_core/test/metaprogramming.cpp
View file @
89cee7a7
...
...
@@ -143,8 +143,7 @@ ostream& operator<<(ostream& out, const pair<bool, int>& x) {
}
// namespace std
CAF_TEST
(
typed_behavior_assignment
)
{
using
bh1
=
typed_beh
<
replies_to
<
int
>::
with
<
double
>
,
replies_to
<
double
,
double
>::
with
<
int
,
int
>>
;
using
bh1
=
typed_beh
<
result
<
double
>
(
int
),
result
<
int
,
int
>
(
double
,
double
)
>
;
// compatible handlers resulting in perfect match
auto
f1
=
[
=
](
int
)
{
return
0.
;
};
auto
f2
=
[
=
](
double
,
double
)
->
result
<
int
,
int
>
{
return
{
0
,
0
};
};
...
...
@@ -171,14 +170,16 @@ CAF_TEST(typed_behavior_assignment) {
CHECK_EQ
(
bi_pair
(
false
,
0
),
tb_assign
<
bh1
>
(
e2
,
f2
));
CHECK_EQ
(
bi_pair
(
false
,
0
),
tb_assign
<
bh1
>
(
e2
,
e1
));
using
bh2
=
typed_beh
<
reacts_to
<
int
>
,
reacts_to
<
int
,
int
>
,
reacts_to
<
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
,
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
>
,
reacts_to
<
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
>>
;
=
typed_beh
<
result
<
void
>
(
int
),
//
result
<
void
>
(
int
,
int
),
//
result
<
void
>
(
int
,
int
,
int
),
//
result
<
void
>
(
int
,
int
,
int
,
int
),
result
<
void
>
(
int
,
int
,
int
,
int
,
int
),
result
<
void
>
(
int
,
int
,
int
,
int
,
int
,
int
),
result
<
void
>
(
int
,
int
,
int
,
int
,
int
,
int
,
int
),
result
<
void
>
(
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
),
result
<
void
>
(
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
),
result
<
void
>
(
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
,
int
)
>
;
auto
h0
=
[](
int
)
{};
auto
h1
=
[](
int
,
int
)
{};
auto
h2
=
[](
int
,
int
,
int
)
{};
...
...
libcaf_core/test/mixin/requester.cpp
View file @
89cee7a7
...
...
@@ -12,29 +12,23 @@
#include "caf/event_based_actor.hpp"
#include "caf/policy/select_all.hpp"
#include "caf/result.hpp"
using
namespace
caf
;
namespace
{
using
discarding_server_type
=
typed_actor
<
re
plies_to
<
int
,
int
>::
with
<
void
>
>
;
using
discarding_server_type
=
typed_actor
<
re
sult
<
void
>
(
int
,
int
)
>
;
using
adding_server_type
=
typed_actor
<
re
plies_to
<
int
,
int
>::
with
<
int
>
>
;
using
adding_server_type
=
typed_actor
<
re
sult
<
int
>
(
int
,
int
)
>
;
using
result_type
=
variant
<
none_t
,
unit_t
,
int
>
;
struct
fixture
:
test_coordinator_fixture
<>
{
fixture
()
{
result
=
std
::
make_shared
<
result_type
>
(
none
);
discarding_server
=
make_server
([](
int
,
int
)
{});
adding_server
=
make_server
([](
int
x
,
int
y
)
{
return
x
+
y
;
});
run
();
}
template
<
class
F
>
auto
make_server
(
F
f
)
->
typed_actor
<
replies_to
<
int
,
int
>::
with
<
decltype
(
f
(
1
,
2
))
>>
{
using
impl
=
typed_actor
<
re
plies_to
<
int
,
int
>::
with
<
decltype
(
f
(
1
,
2
))
>
>
;
auto
make_server
(
F
f
)
{
using
res_t
=
caf
::
result
<
decltype
(
f
(
1
,
2
))
>
;
using
impl
=
typed_actor
<
re
s_t
(
int
,
int
)
>
;
auto
init
=
[
f
]()
->
typename
impl
::
behavior_type
{
return
{
[
f
](
int
x
,
int
y
)
{
return
f
(
x
,
y
);
},
...
...
@@ -43,6 +37,13 @@ struct fixture : test_coordinator_fixture<> {
return
sys
.
spawn
(
init
);
}
fixture
()
{
result
=
std
::
make_shared
<
result_type
>
(
none
);
discarding_server
=
make_server
([](
int
,
int
)
{});
adding_server
=
make_server
([](
int
x
,
int
y
)
{
return
x
+
y
;
});
run
();
}
template
<
class
T
>
T
make_delegator
(
T
dest
)
{
auto
f
=
[
=
](
typename
T
::
pointer
self
)
->
typename
T
::
behavior_type
{
...
...
libcaf_core/test/simple_timeout.cpp
View file @
89cee7a7
...
...
@@ -19,7 +19,7 @@ namespace {
using
ms
=
std
::
chrono
::
milliseconds
;
using
timer
=
typed_actor
<
re
acts_to
<
reset_atom
>
>
;
using
timer
=
typed_actor
<
re
sult
<
void
>
(
reset_atom
)
>
;
struct
timer_state
{
bool
had_reset
=
false
;
...
...
libcaf_core/test/typed_behavior.cpp
View file @
89cee7a7
...
...
@@ -16,9 +16,8 @@
using
namespace
caf
;
CAF_TEST
(
make_typed_behavior
automatically
deduces
its
types
)
{
using
handle
=
typed_actor
<
reacts_to
<
std
::
string
>
,
replies_to
<
int32_t
>::
with
<
int32_t
>
,
replies_to
<
double
>::
with
<
double
>>
;
using
handle
=
typed_actor
<
result
<
void
>
(
std
::
string
),
result
<
int32_t
>
(
int32_t
),
result
<
double
>
(
double
)
>
;
auto
bhvr
=
make_typed_behavior
([](
const
std
::
string
&
)
{},
[](
int32_t
x
)
{
return
x
;
},
[](
double
x
)
{
return
x
;
});
...
...
libcaf_core/test/typed_spawn.cpp
View file @
89cee7a7
...
...
@@ -24,11 +24,6 @@ using namespace std::string_literals;
namespace
{
static_assert
(
std
::
is_same
<
reacts_to
<
int
,
int
>
,
result
<
void
>
(
int
,
int
)
>::
value
);
static_assert
(
std
::
is_same
<
replies_to
<
double
>::
with
<
double
>
,
result
<
double
>
(
double
)
>::
value
);
// check invariants of type system
using
dummy1
=
typed_actor
<
result
<
void
>
(
int
,
int
),
result
<
double
>
(
double
)
>
;
...
...
@@ -38,7 +33,7 @@ static_assert(std::is_convertible<dummy2, dummy1>::value,
"handle not assignable to narrower definition"
);
using
dummy3
=
typed_actor
<
reacts_to
<
float
,
int
>>
;
using
dummy4
=
typed_actor
<
re
plies_to
<
int
>::
with
<
double
>
>
;
using
dummy4
=
typed_actor
<
re
sult
<
double
>
(
int
)
>
;
using
dummy5
=
dummy4
::
extend_with
<
dummy3
>
;
static_assert
(
std
::
is_convertible
<
dummy5
,
dummy3
>::
value
,
...
...
@@ -51,7 +46,7 @@ static_assert(std::is_convertible<dummy5, dummy4>::value,
* simple request/response test *
******************************************************************************/
using
server_type
=
typed_actor
<
re
plies_to
<
my_request
>::
with
<
bool
>
>
;
using
server_type
=
typed_actor
<
re
sult
<
bool
>
(
my_request
)
>
;
server_type
::
behavior_type
typed_server1
()
{
return
{
...
...
@@ -91,9 +86,8 @@ void client(event_based_actor* self, const actor& parent,
******************************************************************************/
using
event_testee_type
=
typed_actor
<
replies_to
<
get_state_atom
>::
with
<
string
>
,
replies_to
<
string
>::
with
<
void
>
,
replies_to
<
float
>::
with
<
void
>
,
replies_to
<
int
>::
with
<
int
>>
;
=
typed_actor
<
result
<
string
>
(
get_state_atom
),
result
<
void
>
(
string
),
result
<
void
>
(
float
),
result
<
int
>
(
int
)
>
;
class
event_testee
:
public
event_testee_type
::
base
{
public:
...
...
@@ -137,7 +131,7 @@ public:
* simple 'forwarding' chain *
******************************************************************************/
using
string_actor
=
typed_actor
<
re
plies_to
<
string
>::
with
<
string
>
>
;
using
string_actor
=
typed_actor
<
re
sult
<
string
>
(
string
)
>
;
string_actor
::
behavior_type
string_reverter
()
{
return
{
...
...
@@ -160,8 +154,7 @@ string_actor::behavior_type string_delegator(string_actor::pointer self,
};
}
using
maybe_string_actor
=
typed_actor
<
replies_to
<
string
>::
with
<
ok_atom
,
string
>>
;
using
maybe_string_actor
=
typed_actor
<
result
<
ok_atom
,
string
>
(
string
)
>
;
maybe_string_actor
::
behavior_type
maybe_string_reverter
()
{
return
{
...
...
@@ -285,7 +278,7 @@ CAF_TEST(typed_spawns) {
CAF_TEST
(
event_testee_series
)
{
auto
et
=
self
->
spawn
<
event_testee
>
();
MESSAGE
(
"et->message_types() returns an interface description"
);
typed_actor
<
re
plies_to
<
get_state_atom
>::
with
<
string
>
>
sub_et
=
et
;
typed_actor
<
re
sult
<
string
>
(
get_state_atom
)
>
sub_et
=
et
;
std
::
set
<
string
>
iface
{
"(get_state_atom) -> (std::string)"
,
"(std::string) -> (void)"
,
"(float) -> (void)"
,
"(int32_t) -> (int32_t)"
};
...
...
@@ -350,7 +343,7 @@ CAF_TEST(sending_typed_actors_and_down_msg) {
}
CAF_TEST
(
check_signature
)
{
using
foo_type
=
typed_actor
<
re
plies_to
<
put_atom
>::
with
<
ok_atom
>
>
;
using
foo_type
=
typed_actor
<
re
sult
<
ok_atom
>
(
put_atom
)
>
;
using
foo_result_type
=
result
<
ok_atom
>
;
using
bar_type
=
typed_actor
<
reacts_to
<
ok_atom
>>
;
auto
foo_action
=
[](
foo_type
::
pointer
ptr
)
->
foo_type
::
behavior_type
{
...
...
libcaf_io/caf/io/middleman_actor.hpp
View file @
89cee7a7
...
...
@@ -71,25 +71,25 @@ namespace caf::io {
///
/// }
/// ~~~
using
middleman_actor
=
typed_actor
<
re
plies_to
<
publish_atom
,
uint16_t
,
strong_actor_ptr
,
std
::
set
<
std
::
string
>
,
std
::
string
,
bool
>::
with
<
uint16_t
>
,
using
middleman_actor
=
typed_actor
<
//
re
sult
<
uint16_t
>
(
publish_atom
,
uint16_t
,
strong_actor_ptr
,
std
::
set
<
std
::
string
>
,
std
::
string
,
bool
)
,
re
plies_to
<
open_atom
,
uint16_t
,
std
::
string
,
bool
>::
with
<
uint16_t
>
,
re
sult
<
uint16_t
>
(
open_atom
,
uint16_t
,
std
::
string
,
bool
)
,
re
plies_to
<
connect_atom
,
std
::
string
,
uint16_t
>::
with
<
node_id
,
strong_actor_ptr
,
std
::
set
<
std
::
string
>>
,
re
sult
<
node_id
,
strong_actor_ptr
,
std
::
set
<
std
::
string
>>
(
connect_atom
,
std
::
string
,
uint16_t
)
,
re
acts_to
<
unpublish_atom
,
actor_addr
,
uint16_t
>
,
re
sult
<
void
>
(
unpublish_atom
,
actor_addr
,
uint16_t
)
,
re
acts_to
<
close_atom
,
uint16_t
>
,
re
sult
<
void
>
(
close_atom
,
uint16_t
)
,
re
plies_to
<
spawn_atom
,
node_id
,
std
::
string
,
message
,
std
::
set
<
std
::
string
>>::
with
<
strong_actor_ptr
>
,
re
sult
<
strong_actor_ptr
>
(
spawn_atom
,
node_id
,
std
::
string
,
message
,
std
::
set
<
std
::
string
>
)
,
re
plies_to
<
get_atom
,
group_atom
,
node_id
,
std
::
string
>::
with
<
actor
>
,
re
sult
<
actor
>
(
get_atom
,
group_atom
,
node_id
,
std
::
string
)
,
re
plies_to
<
get_atom
,
node_id
>::
with
<
node_id
,
std
::
string
,
uint16_t
>
>
;
re
sult
<
node_id
,
std
::
string
,
uint16_t
>
(
get_atom
,
node_id
)
>
;
/// Spawns the default implementation for the `middleman_actor` interface.
CAF_IO_EXPORT
middleman_actor
make_middleman_actor
(
actor_system
&
sys
,
actor
db
);
...
...
libcaf_io/caf/io/typed_broker.hpp
View file @
89cee7a7
...
...
@@ -41,16 +41,16 @@ namespace io {
/// Denotes a minimal "client" broker managing one or more connection
/// handles by reacting to `new_data_msg` and `connection_closed_msg`.
/// @relates typed_broker
using
connection_handler
=
typed_actor
<
re
acts_to
<
new_data_msg
>
,
re
acts_to
<
connection_closed_msg
>
>
;
using
connection_handler
=
typed_actor
<
re
sult
<
void
>
(
new_data_msg
)
,
re
sult
<
void
>
(
connection_closed_msg
)
>
;
/// Denotes a minimal "server" broker managing one or more accept
/// handles by reacting to `new_connection_msg` and `acceptor_closed_msg`.
/// The accept handler usually calls `self->fork(...)` when receiving
/// a `new_connection_msg`.
/// @relates typed_broker
using
accept_handler
=
typed_actor
<
re
acts_to
<
new_connection_msg
>
,
re
acts_to
<
acceptor_closed_msg
>
>
;
using
accept_handler
=
typed_actor
<
re
sult
<
void
>
(
new_connection_msg
)
,
re
sult
<
void
>
(
acceptor_closed_msg
)
>
;
/// A typed broker mediates between actor systems and other
/// components in the network.
...
...
libcaf_io/test/io-test.hpp
View file @
89cee7a7
#include "caf/test/bdd_dsl.hpp"
#include "caf/test/io_dsl.hpp"
using
calculator
=
caf
::
typed_actor
<
caf
::
replies_to
<
caf
::
add_atom
,
int32_t
,
int32_t
>::
with
<
int32_t
>
,
caf
::
replies_to
<
caf
::
sub_atom
,
int32_t
,
int32_t
>::
with
<
int32_t
>
>
;
using
calculator
=
caf
::
typed_actor
<
caf
::
result
<
int32_t
>
(
caf
::
add_atom
,
int32_t
,
int32_t
)
,
caf
::
result
<
int32_t
>
(
caf
::
sub_atom
,
int32_t
,
int32_t
)
>
;
CAF_BEGIN_TYPE_ID_BLOCK
(
io_test
,
caf
::
first_custom_type_id
)
...
...
libcaf_io/test/io/broker.cpp
View file @
89cee7a7
...
...
@@ -121,7 +121,7 @@ behavior peer_acceptor_fun(broker* self, const actor& buddy) {
};
}
using
int_peer
=
connection_handler
::
extend
<
re
plies_to
<
int
>::
with
<
int
>
>
;
using
int_peer
=
connection_handler
::
extend
<
re
sult
<
int
>
(
int
)
>
;
int_peer
::
behavior_type
int_peer_fun
(
int_peer
::
broker_pointer
)
{
return
{
...
...
libcaf_io/test/io/remote_actor.cpp
View file @
89cee7a7
...
...
@@ -58,7 +58,7 @@ behavior pong(event_based_actor* self, suite_state_ptr ssp) {
};
}
using
fragile_mirror_actor
=
typed_actor
<
re
plies_to
<
int
>::
with
<
int
>
>
;
using
fragile_mirror_actor
=
typed_actor
<
re
sult
<
int
>
(
int
)
>
;
fragile_mirror_actor
::
behavior_type
fragile_mirror
(
fragile_mirror_actor
::
pointer
self
)
{
...
...
manual/Actors.rst
View file @
89cee7a7
...
...
@@ -240,13 +240,14 @@ Statically typed actors require abstract messaging interfaces to allow the
compiler to type-check actor communication. Interfaces in CAF are defined using
the variadic template ``typed_actor<...>``, which defines the proper
actor handle at the same time. Each template parameter defines one
``input/output`` pair via
``replies_to<X1,...,Xn>::with<Y1,...,Yn>``. For inputs that do not
generate outputs, ``reacts_to<X1,...,Xn>`` can be used as shortcut for
``replies_to<X1,...,Xn>::with<void>``. In the same way functions cannot
be overloaded only by their return type, interfaces cannot accept one input
twice (possibly mapping it to different outputs). The example below defines a
messaging interface for a simple calculator.
``input/output`` pair via function signature syntax with the return type wrapped
in a ``result``. For example, ``typed_actor<result<string, string>(double)>``.
Also, the arguments must not use any cv-qualifiers.
In the same way functions cannot be overloaded only by their return type,
interfaces cannot accept one input twice (possibly mapping it to different
outputs). The example below defines a messaging interface for a simple
calculator.
.. literalinclude:: /examples/message_passing/calculator.cpp
:language: C++
...
...
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