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
938f8668
Commit
938f8668
authored
Aug 19, 2019
by
Jakob Otto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mixin for string_application
parent
9ccb5dc6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
7 deletions
+16
-7
libcaf_net/test/string_application.cpp
libcaf_net/test/string_application.cpp
+16
-7
No files found.
libcaf_net/test/string_application.cpp
View file @
938f8668
...
@@ -70,6 +70,8 @@ typename Inspector::result_type inspect(Inspector& f,
...
@@ -70,6 +70,8 @@ typename Inspector::result_type inspect(Inspector& f,
return
f
(
meta
::
type_name
(
"sa_header"
),
hdr
.
payload
);
return
f
(
meta
::
type_name
(
"sa_header"
),
hdr
.
payload
);
}
}
struct
end_application
{};
class
string_application
{
class
string_application
{
public:
public:
using
header_type
=
string_application_header
;
using
header_type
=
string_application_header
;
...
@@ -121,11 +123,14 @@ private:
...
@@ -121,11 +123,14 @@ private:
std
::
shared_ptr
<
std
::
vector
<
char
>>
buf_
;
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:
public:
using
header_type
=
typename
Base
::
header_type
;
stream_string_application
(
actor_system
&
sys
,
stream_string_application
(
actor_system
&
sys
,
std
::
shared_ptr
<
std
::
vector
<
char
>>
buf
)
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
// nop
}
}
...
@@ -133,20 +138,20 @@ public:
...
@@ -133,20 +138,20 @@ public:
error
init
(
Parent
&
parent
)
{
error
init
(
Parent
&
parent
)
{
parent
.
transport
().
configure_read
(
parent
.
transport
().
configure_read
(
net
::
receive_policy
::
exactly
(
sizeof
(
header_type
)));
net
::
receive_policy
::
exactly
(
sizeof
(
header_type
)));
return
string_application
::
init
(
parent
);
return
Base
::
init
(
parent
);
}
}
template
<
class
Parent
>
template
<
class
Parent
>
void
handle_data
(
Parent
&
parent
,
span
<
char
>
data
)
{
void
handle_data
(
Parent
&
parent
,
span
<
char
>
data
)
{
if
(
await_payload_
)
{
if
(
await_payload_
)
{
handle_packet
(
parent
,
header_
,
data
);
Base
::
handle_packet
(
parent
,
header_
,
data
);
await_payload_
=
false
;
await_payload_
=
false
;
}
else
{
}
else
{
if
(
data
.
size
()
!=
sizeof
(
header_type
))
if
(
data
.
size
()
!=
sizeof
(
header_type
))
CAF_FAIL
(
""
);
CAF_FAIL
(
""
);
memcpy
(
&
header_
,
data
.
data
(),
sizeof
(
header_type
));
memcpy
(
&
header_
,
data
.
data
(),
sizeof
(
header_type
));
if
(
header_
.
payload
==
0
)
if
(
header_
.
payload
==
0
)
handle_packet
(
parent
,
header_
,
span
<
char
>
{});
Base
::
handle_packet
(
parent
,
header_
,
span
<
char
>
{});
else
else
parent
.
configure_read
(
net
::
receive_policy
::
exactly
(
header_
.
payload
));
parent
.
configure_read
(
net
::
receive_policy
::
exactly
(
header_
.
payload
));
await_payload_
=
true
;
await_payload_
=
true
;
...
@@ -194,12 +199,16 @@ CAF_TEST(receive) {
...
@@ -194,12 +199,16 @@ CAF_TEST(receive) {
sec
::
unavailable_or_would_block
);
sec
::
unavailable_or_would_block
);
CAF_MESSAGE
(
"adding both endpoint managers"
);
CAF_MESSAGE
(
"adding both endpoint managers"
);
auto
mgr1
=
make_endpoint_manager
(
mpx
,
sys
,
policy
::
scribe
{
sockets
.
first
},
auto
mgr1
=
make_endpoint_manager
(
mpx
,
sys
,
policy
::
scribe
{
sockets
.
first
},
stream_string_application
{
sys
,
buf
});
stream_string_application
<
string_application
,
end_application
>
{
sys
,
buf
});
CAF_CHECK_EQUAL
(
mgr1
->
init
(),
none
);
CAF_CHECK_EQUAL
(
mgr1
->
init
(),
none
);
mpx
->
handle_updates
();
mpx
->
handle_updates
();
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
2u
);
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
2u
);
auto
mgr2
=
make_endpoint_manager
(
mpx
,
sys
,
policy
::
scribe
{
sockets
.
second
},
auto
mgr2
=
make_endpoint_manager
(
mpx
,
sys
,
policy
::
scribe
{
sockets
.
second
},
stream_string_application
{
sys
,
buf
});
stream_string_application
<
string_application
,
end_application
>
{
sys
,
buf
});
CAF_CHECK_EQUAL
(
mgr2
->
init
(),
none
);
CAF_CHECK_EQUAL
(
mgr2
->
init
(),
none
);
mpx
->
handle_updates
();
mpx
->
handle_updates
();
CAF_CHECK_EQUAL
(
mpx
->
num_socket_managers
(),
3u
);
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