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
aee508be
Commit
aee508be
authored
Aug 20, 2019
by
Dominik Charousset
Committed by
GitHub
Aug 20, 2019
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #14
Fix mixin for string_application
parents
68451a12
36c7ac33
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
7 deletions
+12
-7
libcaf_net/test/string_application.cpp
libcaf_net/test/string_application.cpp
+12
-7
No files found.
libcaf_net/test/string_application.cpp
View file @
aee508be
...
...
@@ -121,11 +121,14 @@ private:
std
::
shared_ptr
<
std
::
vector
<
char
>>
buf_
;
};
class
stream_string_application
:
public
string_application
{
template
<
class
Base
,
class
Subtype
>
class
stream_string_application
:
public
Base
{
public:
using
header_type
=
typename
Base
::
header_type
;
stream_string_application
(
actor_system
&
sys
,
std
::
shared_ptr
<
std
::
vector
<
char
>>
buf
)
:
string_application
(
sys
,
std
::
move
(
buf
)),
await_payload_
(
false
)
{
:
Base
(
sys
,
std
::
move
(
buf
)),
await_payload_
(
false
)
{
// nop
}
...
...
@@ -133,20 +136,20 @@ public:
error
init
(
Parent
&
parent
)
{
parent
.
transport
().
configure_read
(
net
::
receive_policy
::
exactly
(
sizeof
(
header_type
)));
return
string_application
::
init
(
parent
);
return
Base
::
init
(
parent
);
}
template
<
class
Parent
>
void
handle_data
(
Parent
&
parent
,
span
<
char
>
data
)
{
if
(
await_payload_
)
{
handle_packet
(
parent
,
header_
,
data
);
Base
::
handle_packet
(
parent
,
header_
,
data
);
await_payload_
=
false
;
}
else
{
if
(
data
.
size
()
!=
sizeof
(
header_type
))
CAF_FAIL
(
""
);
memcpy
(
&
header_
,
data
.
data
(),
sizeof
(
header_type
));
if
(
header_
.
payload
==
0
)
handle_packet
(
parent
,
header_
,
span
<
char
>
{});
Base
::
handle_packet
(
parent
,
header_
,
span
<
char
>
{});
else
parent
.
configure_read
(
net
::
receive_policy
::
exactly
(
header_
.
payload
));
await_payload_
=
true
;
...
...
@@ -185,6 +188,8 @@ private:
CAF_TEST_FIXTURE_SCOPE
(
endpoint_manager_tests
,
fixture
)
CAF_TEST
(
receive
)
{
using
application_type
=
extend
<
string_application
>::
with
<
stream_string_application
>
;
std
::
vector
<
char
>
read_buf
(
1024
);
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
1u
);
auto
buf
=
std
::
make_shared
<
std
::
vector
<
char
>>
();
...
...
@@ -194,12 +199,12 @@ CAF_TEST(receive) {
sec
::
unavailable_or_would_block
);
CAF_MESSAGE
(
"adding both endpoint managers"
);
auto
mgr1
=
make_endpoint_manager
(
mpx
,
sys
,
policy
::
scribe
{
sockets
.
first
},
stream_string_application
{
sys
,
buf
});
application_type
{
sys
,
buf
});
CAF_CHECK_EQUAL
(
mgr1
->
init
(),
none
);
mpx
->
handle_updates
();
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
2u
);
auto
mgr2
=
make_endpoint_manager
(
mpx
,
sys
,
policy
::
scribe
{
sockets
.
second
},
stream_string_application
{
sys
,
buf
});
application_type
{
sys
,
buf
});
CAF_CHECK_EQUAL
(
mgr2
->
init
(),
none
);
mpx
->
handle_updates
();
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
3u
);
...
...
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