Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
A
actor-incubator
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
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-incubator
Commits
b09edcb0
Commit
b09edcb0
authored
Aug 21, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into topic/span-refactoring
parents
bd83338c
a0192a41
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
40 deletions
+19
-40
libcaf_net/caf/net/write_packet_decorator.hpp
libcaf_net/caf/net/write_packet_decorator.hpp
+19
-40
No files found.
libcaf_net/caf/net/
dispatche
r.hpp
→
libcaf_net/caf/net/
write_packet_decorato
r.hpp
View file @
b09edcb0
...
...
@@ -22,70 +22,49 @@ namespace caf {
namespace
net
{
/// Implements the interface for transport and application policies and
/// dispatches member functions either to `decorator` or `
fallback
`.
template
<
class
Decorator
,
class
Fallback
>
class
dispatche
r
{
/// dispatches member functions either to `decorator` or `
parent
`.
template
<
class
Object
,
class
Parent
>
class
write_packet_decorato
r
{
public:
dispatcher
(
Decorator
&
decorator
,
Fallback
&
fallback
)
:
decorator_
(
decorator
),
fallback_
(
fallback
)
{
dispatcher
(
Object
&
object
,
Parent
&
parent
)
:
object_
(
object
),
parent_
(
parent
)
{
// nop
}
template
<
class
Header
>
void
write_packet
(
const
Header
&
header
,
span
<
const
byte
>
payload
)
{
decltype
(
write_packet_delegate_test
<
Decorator
>
(
nullptr
,
header
,
payload
))
x
;
write_packet_delegate
(
x
,
header
,
payload
);
object_
.
write_packet
(
parent_
,
header
,
payload
);
}
actor_system
&
system
()
{
fallback
_
.
system
();
parent
_
.
system
();
}
void
cancel_timeout
(
atom_value
type
,
uint64_t
id
)
{
fallback
_
.
cancel_timeout
(
type
,
id
);
parent
_
.
cancel_timeout
(
type
,
id
);
}
void
set_timeout
(
timestamp
tout
,
atom_value
type
,
uint64_t
id
)
{
fallback
_
.
set_timeout
(
tout
,
type
,
id
);
parent
_
.
set_timeout
(
tout
,
type
,
id
);
}
typename
Fallback
::
transport_type
&
transport
()
{
return
fallback
_
.
transport_
;
typename
parent
::
transport_type
&
transport
()
{
return
parent
_
.
transport_
;
}
typename
Fallback
::
application_type
&
application
()
{
return
fallback
_
.
application_
;
typename
parent
::
application_type
&
application
()
{
return
parent
_
.
application_
;
}
private:
template
<
class
U
,
class
Header
>
static
auto
write_packet_delegate_test
(
U
*
x
,
const
Header
&
hdr
,
span
<
const
byte
>
payload
)
->
decltype
(
x
->
write_packet
(
hdr
,
payload
),
std
::
true_type
());
template
<
class
U
>
static
auto
write_packet_delegate_test
(...)
->
std
::
false_type
;
template
<
class
Header
>
void
write_packet_delegate
(
std
::
true_type
,
const
Header
&
header
,
span
<
const
byte
>
payload
)
{
decorator_
.
write_packet
(
header
,
payload
);
}
template
<
class
Header
>
void
write_packet_delegate
(
std
::
false_type
,
const
Header
&
header
,
span
<
const
byte
>
payload
)
{
fallback_
.
write_packet
(
header
,
payload
);
}
Object
&
decorator_
;
Fallback
&
fallback_
;
Object
&
object_
;
Parent
&
parent_
;
};
template
<
class
Decorator
,
class
Fallback
>
dispatcher
<
Decorator
,
Fallback
>
make_dispatcher
(
Decorator
&
decorator
,
Fallback
&
fallback
)
{
return
{
decorator
,
fallback
};
template
<
class
Object
,
class
Parent
>
write_packet_decorator
<
Object
,
Parent
>
make_write_packet_decorator
(
Object
&
object
,
Parent
&
parent
)
{
return
{
object
,
parent
};
}
}
// namespace net
...
...
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