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
269acb49
Commit
269acb49
authored
Mar 09, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Move typed_broker out of experimental namespace
parent
28747e3f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
45 additions
and
53 deletions
+45
-53
libcaf_core/caf/infer_handle.hpp
libcaf_core/caf/infer_handle.hpp
+4
-7
libcaf_core/caf/typed_actor.hpp
libcaf_core/caf/typed_actor.hpp
+2
-4
libcaf_io/caf/io/all.hpp
libcaf_io/caf/io/all.hpp
+1
-0
libcaf_io/caf/io/typed_broker.hpp
libcaf_io/caf/io/typed_broker.hpp
+36
-31
libcaf_io/test/typed_broker.cpp
libcaf_io/test/typed_broker.cpp
+2
-11
No files found.
libcaf_core/caf/infer_handle.hpp
View file @
269acb49
...
...
@@ -32,12 +32,10 @@ template <class... Sigs>
class
typed_event_based_actor
;
namespace
io
{
namespace
experimental
{
template
<
class
...
Sigs
>
class
typed_broker
;
}
// namespace experimental
}
// namespace io
enum
class
spawn_mode
{
...
...
@@ -117,10 +115,10 @@ struct infer_handle_from_fun_impl<Result,
// statically typed broker with self pointer
template
<
class
Result
,
class
...
Sigs
>
struct
infer_handle_from_fun_impl
<
Result
,
io
::
experimental
::
typed_broker
<
Sigs
...
>*
,
io
::
typed_broker
<
Sigs
...
>*
,
true
>
{
using
type
=
typed_actor
<
Sigs
...
>
;
using
impl
=
io
::
experimental
::
typed_broker
<
Sigs
...
>
;
using
impl
=
io
::
typed_broker
<
Sigs
...
>
;
using
behavior_type
=
typed_behavior
<
Sigs
...
>
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
};
...
...
@@ -130,14 +128,14 @@ template <class Result, class State, class... Sigs>
struct
infer_handle_from_fun_impl
<
Result
,
stateful_actor
<
State
,
io
::
experimental
::
typed_broker
<
Sigs
...
>
io
::
typed_broker
<
Sigs
...
>
>*
,
true
>
{
using
type
=
typed_actor
<
Sigs
...
>
;
using
impl
=
stateful_actor
<
State
,
io
::
experimental
::
typed_broker
<
Sigs
...
>
io
::
typed_broker
<
Sigs
...
>
>
;
using
behavior_type
=
typed_behavior
<
Sigs
...
>
;
static
constexpr
spawn_mode
mode
=
spawn_mode
::
function_with_selfptr
;
...
...
@@ -214,4 +212,3 @@ using infer_handle_from_state_t = typename infer_handle_from_state<T>::type;
}
// namespace caf
#endif // CAF_INFER_HANDLE_HPP
libcaf_core/caf/typed_actor.hpp
View file @
269acb49
...
...
@@ -44,12 +44,10 @@ template <class... Sigs>
class
typed_event_based_actor
;
namespace
io
{
namespace
experimental
{
template
<
class
...
Sigs
>
class
typed_broker
;
}
// namespace experimental
}
// namespace io
/// Identifies a statically typed actor.
...
...
@@ -96,10 +94,10 @@ class typed_actor : detail::comparable<typed_actor<Sigs...>>,
using
base
=
typed_event_based_actor
<
Sigs
...
>
;
/// Identifies pointers to brokers implementing this interface.
using
broker_pointer
=
io
::
experimental
::
typed_broker
<
Sigs
...
>*
;
using
broker_pointer
=
io
::
typed_broker
<
Sigs
...
>*
;
/// Identifies the base class of brokers implementing this interface.
using
broker_base
=
io
::
experimental
::
typed_broker
<
Sigs
...
>
;
using
broker_base
=
io
::
typed_broker
<
Sigs
...
>
;
/// Stores the template parameter pack.
using
signatures
=
detail
::
type_list
<
Sigs
...
>
;
...
...
libcaf_io/caf/io/all.hpp
View file @
269acb49
...
...
@@ -24,6 +24,7 @@
#include "caf/io/broker.hpp"
#include "caf/io/middleman.hpp"
#include "caf/io/basp_broker.hpp"
#include "caf/io/typed_broker.hpp"
#include "caf/io/receive_policy.hpp"
#include "caf/io/middleman_actor.hpp"
#include "caf/io/system_messages.hpp"
...
...
libcaf_io/caf/io/
experimental/
typed_broker.hpp
→
libcaf_io/caf/io/typed_broker.hpp
View file @
269acb49
...
...
@@ -17,8 +17,8 @@
* http://www.boost.org/LICENSE_1_0.txt. *
******************************************************************************/
#ifndef CAF_IO_
EXPERIMENTAL_
TYPED_BROKER_HPP
#define CAF_IO_
EXPERIMENTAL_
TYPED_BROKER_HPP
#ifndef CAF_IO_TYPED_BROKER_HPP
#define CAF_IO_TYPED_BROKER_HPP
#include <map>
#include <vector>
...
...
@@ -41,20 +41,26 @@
namespace
caf
{
namespace
io
{
namespace
experimental
{
using
minimal_client
=
typed_actor
<
reacts_to
<
new_data_msg
>
,
reacts_to
<
connection_closed_msg
>>
;
using
minimal_server
=
minimal_client
::
extend
<
reacts_to
<
new_connection_msg
>
,
reacts_to
<
acceptor_closed_msg
>>
;
template
<
class
...
Sigs
>
class
typed_broker
;
/// A typed broker mediates between actor systems and other components in
/// the network.
/// 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
<
reacts_to
<
new_data_msg
>
,
reacts_to
<
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
<
reacts_to
<
new_connection_msg
>
,
reacts_to
<
acceptor_closed_msg
>>
;
/// A typed broker mediates between actor systems and other
/// components in the network.
/// @extends local_actor
template
<
class
...
Sigs
>
class
typed_broker
:
public
abstract_event_based_actor
<
typed_behavior
<
Sigs
...
>
,
...
...
@@ -72,11 +78,11 @@ public:
using
super
::
send
;
using
super
::
delayed_send
;
template
<
class
...
Dest
Sigs
,
class
...
Ts
>
void
send
(
message_priority
mp
,
const
typed_actor
<
Dest
Sigs
...
>&
dest
,
Ts
&&
...
xs
)
{
template
<
class
...
Dest
,
class
...
Ts
>
void
send
(
message_priority
mp
,
const
typed_actor
<
Dest
...
>&
dest
,
Ts
&&
...
xs
)
{
detail
::
sender_signature_checker
<
detail
::
type_list
<
Sigs
...
>
,
detail
::
type_list
<
Dest
Sigs
...
>
,
detail
::
type_list
<
Dest
...
>
,
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
std
::
decay
<
Ts
>::
type
...
...
@@ -86,11 +92,11 @@ public:
super
::
send
(
mp
,
dest
,
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
...
Dest
Sigs
,
class
...
Ts
>
void
send
(
const
typed_actor
<
Dest
Sigs
...
>&
dest
,
Ts
&&
...
xs
)
{
template
<
class
...
Dest
,
class
...
Ts
>
void
send
(
const
typed_actor
<
Dest
...
>&
dest
,
Ts
&&
...
xs
)
{
detail
::
sender_signature_checker
<
detail
::
type_list
<
Sigs
...
>
,
detail
::
type_list
<
Dest
Sigs
...
>
,
detail
::
type_list
<
Dest
...
>
,
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
std
::
decay
<
Ts
>::
type
...
...
@@ -100,12 +106,12 @@ public:
super
::
send
(
dest
,
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
...
Dest
Sigs
,
class
...
Ts
>
void
delayed_send
(
message_priority
mp
,
const
typed_actor
<
Dest
Sigs
...
>&
dest
,
template
<
class
...
Dest
,
class
...
Ts
>
void
delayed_send
(
message_priority
mp
,
const
typed_actor
<
Dest
...
>&
dest
,
const
duration
&
rtime
,
Ts
&&
...
xs
)
{
detail
::
sender_signature_checker
<
detail
::
type_list
<
Sigs
...
>
,
detail
::
type_list
<
Dest
Sigs
...
>
,
detail
::
type_list
<
Dest
...
>
,
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
std
::
decay
<
Ts
>::
type
...
...
@@ -115,12 +121,12 @@ public:
super
::
delayed_send
(
mp
,
dest
,
rtime
,
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
...
Dest
Sigs
,
class
...
Ts
>
void
delayed_send
(
const
typed_actor
<
Dest
Sigs
...
>&
dest
,
template
<
class
...
Dest
,
class
...
Ts
>
void
delayed_send
(
const
typed_actor
<
Dest
...
>&
dest
,
const
duration
&
rtime
,
Ts
&&
...
xs
)
{
detail
::
sender_signature_checker
<
detail
::
type_list
<
Sigs
...
>
,
detail
::
type_list
<
Dest
Sigs
...
>
,
detail
::
type_list
<
Dest
...
>
,
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
std
::
decay
<
Ts
>::
type
...
...
@@ -158,7 +164,7 @@ public:
using
impl
=
typename
infer_handle_from_fun
<
F
>::
impl
;
static_assert
(
std
::
is_convertible
<
typename
impl
::
actor_hdl
,
minimal_client
connection_handler
>::
value
,
"Cannot fork: new broker misses required handlers"
);
actor_config
cfg
{
this
->
context
()};
...
...
@@ -173,13 +179,13 @@ public:
}
connection_handle
add_tcp_scribe
(
const
std
::
string
&
host
,
uint16_t
port
)
{
static_assert
(
std
::
is_convertible
<
actor_hdl
,
minimal_client
>::
value
,
static_assert
(
std
::
is_convertible
<
actor_hdl
,
connection_handler
>::
value
,
"Cannot add scribe: broker misses required handlers"
);
return
super
::
add_tcp_scribe
(
host
,
port
);
}
connection_handle
add_tcp_scribe
(
network
::
native_socket
fd
)
{
static_assert
(
std
::
is_convertible
<
actor_hdl
,
minimal_client
>::
value
,
static_assert
(
std
::
is_convertible
<
actor_hdl
,
connection_handler
>::
value
,
"Cannot add scribe: broker misses required handlers"
);
return
super
::
add_tcp_scribe
(
fd
);
}
...
...
@@ -188,13 +194,13 @@ public:
add_tcp_doorman
(
uint16_t
port
=
0
,
const
char
*
in
=
nullptr
,
bool
reuse_addr
=
false
)
{
static_assert
(
std
::
is_convertible
<
actor_hdl
,
minimal_serv
er
>::
value
,
static_assert
(
std
::
is_convertible
<
actor_hdl
,
accept_handl
er
>::
value
,
"Cannot add doorman: broker misses required handlers"
);
return
super
::
add_tcp_doorman
(
port
,
in
,
reuse_addr
);
}
accept_handle
add_tcp_doorman
(
network
::
native_socket
fd
)
{
static_assert
(
std
::
is_convertible
<
actor_hdl
,
minimal_serv
er
>::
value
,
static_assert
(
std
::
is_convertible
<
actor_hdl
,
accept_handl
er
>::
value
,
"Cannot add doorman: broker misses required handlers"
);
return
super
::
add_tcp_doorman
(
fd
);
}
...
...
@@ -215,8 +221,7 @@ protected:
}
};
}
// namespace experimental
}
// namespace io
}
// namespace caf
#endif // CAF_IO_
EXPERIMENTAL_
TYPED_BROKER_HPP
#endif // CAF_IO_TYPED_BROKER_HPP
libcaf_io/test/typed_broker.cpp
View file @
269acb49
...
...
@@ -28,14 +28,11 @@
#include "caf/all.hpp"
#include "caf/io/all.hpp"
#include "caf/io/experimental/typed_broker.hpp"
#include "caf/string_algorithms.hpp"
using
namespace
std
;
using
namespace
caf
;
using
namespace
caf
::
io
;
using
namespace
caf
::
io
::
experimental
;
namespace
{
...
...
@@ -44,11 +41,11 @@ using ping_atom = caf::atom_constant<atom("ping")>;
using
pong_atom
=
caf
::
atom_constant
<
atom
(
"pong"
)
>
;
using
kickoff_atom
=
caf
::
atom_constant
<
atom
(
"kickoff"
)
>
;
using
peer
=
minimal_client
::
extend
<
reacts_to
<
ping_atom
,
int
>
,
using
peer
=
connection_handler
::
extend
<
reacts_to
<
ping_atom
,
int
>
,
reacts_to
<
pong_atom
,
int
>>
;
using
acceptor
=
minimal_serv
er
::
extend
<
replies_to
<
publish_atom
>::
with
<
uint16_t
>>
;
accept_handl
er
::
extend
<
replies_to
<
publish_atom
>::
with
<
uint16_t
>>
;
behavior
ping
(
event_based_actor
*
self
,
size_t
num_pings
)
{
CAF_MESSAGE
(
"num_pings: "
<<
num_pings
);
...
...
@@ -165,12 +162,6 @@ acceptor::behavior_type acceptor_fun(acceptor::broker_pointer self,
self
->
fork
(
peer_fun
,
msg
.
handle
,
buddy
);
self
->
quit
();
},
[](
const
new_data_msg
&
)
{
// nop
},
[](
const
connection_closed_msg
&
)
{
// nop
},
[](
const
acceptor_closed_msg
&
)
{
// nop
},
...
...
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