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
9b46d1de
Commit
9b46d1de
authored
Aug 20, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Plain Diff
Resolve conflicts with master
parents
742e95b0
18fdd027
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 @
9b46d1de
...
...
@@ -122,11 +122,14 @@ private:
std
::
shared_ptr
<
std
::
vector
<
byte
>>
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
<
byte
>>
buf
)
:
string_application
(
sys
,
std
::
move
(
buf
)),
await_payload_
(
false
)
{
:
Base
(
sys
,
std
::
move
(
buf
)),
await_payload_
(
false
)
{
// nop
}
...
...
@@ -134,20 +137,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
<
const
byte
>
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
<
const
byte
>
{});
Base
::
handle_packet
(
parent
,
header_
,
span
<
const
byte
>
{});
else
parent
.
configure_read
(
net
::
receive_policy
::
exactly
(
header_
.
payload
));
await_payload_
=
true
;
...
...
@@ -186,6 +189,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
<
byte
>
read_buf
(
1024
);
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
1u
);
auto
buf
=
std
::
make_shared
<
std
::
vector
<
byte
>>
();
...
...
@@ -195,12 +200,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