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
a58ce6c1
Commit
a58ce6c1
authored
Jul 16, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add some notes and empty funs to policies
parent
063b630a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
22 deletions
+35
-22
examples/remoting/newbc.cpp
examples/remoting/newbc.cpp
+1
-1
libcaf_io/caf/io/network/newb.hpp
libcaf_io/caf/io/network/newb.hpp
+34
-21
No files found.
examples/remoting/newbc.cpp
View file @
a58ce6c1
...
...
@@ -53,7 +53,7 @@ void caf_main(actor_system& system, const config&) {
// Create an event handling actor to run in the multiplexer.
actor_config
cfg
{
&
mpx
};
auto
n
=
make_newb
<
detail
::
protocol_policy
,
detail
::
generic
_policy
>
(
system
,
cfg
,
mpx
,
-
1
);
detail
::
mutating
_policy
>
(
system
,
cfg
,
mpx
,
-
1
);
anon_send
(
n
,
1
);
t
.
join
();
}
...
...
libcaf_io/caf/io/network/newb.hpp
View file @
a58ce6c1
...
...
@@ -48,38 +48,51 @@ public:
namespace
detail
{
struct
generic_policy
{
generic_policy
(
int
i
)
// Policies provide a newb with functionality. A protocol policy implements a
// network protocol and provides implementations to read and write data as well
// as for forking to new event handlers.
//
// After receiving data the policy stack of a newb is called in order to
struct
protocol_policy
{
protocol_policy
(
int
i
)
:
idx
{
i
}
{
// nop
}
int
idx
;
};
struct
protocol_policy
:
public
generic_policy
{
protocol_policy
(
int
i
)
:
generic_policy
{
i
}
{
// nop
void
read
()
{
}
// define a base protocol
// - create a socket
// - sending
// * enqueue
// *
// - receiving
// - fork
void
write
()
{
}
void
fork
()
{
}
int
idx
;
};
struct
mutating_policy
:
public
generic_policy
{
struct
mutating_policy
{
mutating_policy
(
int
i
)
:
generic_policy
{
i
}
{
:
idx
{
i
}
{
// nop
}
// adjust a protocol
// Call on incoming data. Should return either a bool or a enum to
// know if furhter policies are called and how to continue processing.
void
handle
()
{
}
int
idx
;
};
template
<
class
T
>
struct
is_network_policy_type
:
std
::
is_base_of
<
generic_policy
,
T
>
{};
struct
is_protocol_policy_type
:
std
::
is_base_of
<
protocol_policy
,
T
>
{};
template
<
class
T
>
struct
is_mutating_policy_type
:
std
::
is_base_of
<
mutating_policy
,
T
>
{};
}
// namespace detail
...
...
@@ -232,8 +245,8 @@ private:
template
<
class
Protocol
,
class
...
Policies
>
actor
make_newb
(
actor_system
&
sys
,
actor_config
&
cfg
,
default_multiplexer
&
mpx
,
native_socket
sockfd
)
{
using
policy_types
=
detail
::
type_list
<
P
rotocol
,
P
olicies
...
>
;
static_assert
(
detail
::
tl_forall
<
policy_types
,
detail
::
is_
network
_policy_type
>::
value
,
using
policy_types
=
detail
::
type_list
<
Policies
...
>
;
static_assert
(
detail
::
tl_forall
<
policy_types
,
detail
::
is_
mutating
_policy_type
>::
value
,
"Only network policies allowed as template parameters"
);
static_assert
(
std
::
is_base_of
<
detail
::
protocol_policy
,
Protocol
>::
value
,
"First template argument must be a protocol policy"
);
...
...
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