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
c151505b
Commit
c151505b
authored
Aug 28, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adapt to timeout and message handler changes
parent
f4f473d7
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
71 deletions
+37
-71
examples/remoting/basp_tcp_newb.cpp
examples/remoting/basp_tcp_newb.cpp
+6
-13
examples/remoting/basp_udp_newb.cpp
examples/remoting/basp_udp_newb.cpp
+6
-13
examples/remoting/raw_tcp_newb.cpp
examples/remoting/raw_tcp_newb.cpp
+4
-11
examples/remoting/raw_udp_newb.cpp
examples/remoting/raw_udp_newb.cpp
+4
-11
libcaf_io/test/protocol_policy.cpp
libcaf_io/test/protocol_policy.cpp
+17
-23
No files found.
examples/remoting/basp_tcp_newb.cpp
View file @
c151505b
...
...
@@ -131,22 +131,15 @@ struct basp_newb : public io::network::newb<new_basp_message> {
CAF_LOG_TRACE
(
""
);
}
void
handle
(
new_basp_message
&
msg
)
override
{
CAF_PUSH_AID_FROM_PTR
(
this
);
CAF_LOG_TRACE
(
""
);
std
::
string
res
;
binary_deserializer
bd
(
&
backend
(),
msg
.
payload
,
msg
.
payload_len
);
bd
(
res
);
send
(
responder
,
res
);
}
behavior
make_behavior
()
override
{
set_default_handler
(
print_and_drop
);
return
{
// Must be implemented at the moment, will be cought by the broker in a
// later implementation.
[
=
](
atom_value
atm
,
uint32_t
id
)
{
protocol
->
timeout
(
atm
,
id
);
[
=
](
new_basp_message
&
msg
)
{
CAF_LOG_TRACE
(
""
);
std
::
string
res
;
binary_deserializer
bd
(
&
backend
(),
msg
.
payload
,
msg
.
payload_len
);
bd
(
res
);
send
(
responder
,
res
);
},
[
=
](
send_atom
,
actor_id
sender
,
actor_id
receiver
,
std
::
string
payload
)
{
auto
hw
=
caf
::
make_callback
([
&
](
io
::
network
::
byte_buffer
&
buf
)
->
error
{
...
...
examples/remoting/basp_udp_newb.cpp
View file @
c151505b
...
...
@@ -245,22 +245,15 @@ struct basp_newb : public io::network::newb<new_basp_message> {
// nop
}
void
handle
(
new_basp_message
&
msg
)
override
{
CAF_PUSH_AID_FROM_PTR
(
this
);
CAF_LOG_TRACE
(
""
);
std
::
string
res
;
binary_deserializer
bd
(
&
backend
(),
msg
.
payload
,
msg
.
payload_len
);
bd
(
res
);
send
(
responder
,
res
);
}
behavior
make_behavior
()
override
{
set_default_handler
(
print_and_drop
);
return
{
// Must be implemented at the moment, will be cought by the broker in a
// later implementation.
[
=
](
atom_value
atm
,
uint32_t
id
)
{
protocol
->
timeout
(
atm
,
id
);
[
=
](
new_basp_message
&
msg
)
{
CAF_LOG_TRACE
(
""
);
std
::
string
res
;
binary_deserializer
bd
(
&
backend
(),
msg
.
payload
,
msg
.
payload_len
);
bd
(
res
);
send
(
responder
,
res
);
},
[
=
](
send_atom
,
actor_id
sender
,
actor_id
receiver
,
std
::
string
payload
)
{
auto
hw
=
caf
::
make_callback
([
&
](
io
::
network
::
byte_buffer
&
buf
)
->
error
{
...
...
examples/remoting/raw_tcp_newb.cpp
View file @
c151505b
...
...
@@ -79,20 +79,13 @@ struct raw_newb : public io::network::newb<new_data> {
CAF_LOG_TRACE
(
""
);
}
void
handle
(
message_type
&
msg
)
override
{
CAF_PUSH_AID_FROM_PTR
(
this
);
CAF_LOG_TRACE
(
""
);
char
res
=
*
msg
.
payload
;
send
(
responder
,
res
);
}
behavior
make_behavior
()
override
{
set_default_handler
(
print_and_drop
);
return
{
// Must be implemented at the moment, will be cought by the broker in a
// later implementation.
[
=
](
atom_value
atm
,
uint32_t
id
)
{
protocol
->
timeout
(
atm
,
id
);
[
=
](
message_type
&
msg
)
{
CAF_LOG_TRACE
(
""
);
char
res
=
*
msg
.
payload
;
send
(
responder
,
res
);
},
[
=
](
send_atom
,
char
c
)
{
auto
whdl
=
wr_buf
(
nullptr
);
...
...
examples/remoting/raw_udp_newb.cpp
View file @
c151505b
...
...
@@ -77,20 +77,13 @@ struct raw_newb : public io::network::newb<new_data> {
CAF_LOG_TRACE
(
""
);
}
void
handle
(
message_type
&
msg
)
override
{
CAF_PUSH_AID_FROM_PTR
(
this
);
CAF_LOG_TRACE
(
""
);
char
res
=
*
msg
.
payload
;
send
(
responder
,
res
);
}
behavior
make_behavior
()
override
{
set_default_handler
(
print_and_drop
);
return
{
// Must be implemented at the moment, will be cought by the broker in a
// later implementation.
[
=
](
atom_value
atm
,
uint32_t
id
)
{
protocol
->
timeout
(
atm
,
id
);
[
=
](
message_type
&
msg
)
{
CAF_LOG_TRACE
(
""
);
char
res
=
*
msg
.
payload
;
send
(
responder
,
res
);
},
[
=
](
send_atom
,
char
c
)
{
auto
whdl
=
wr_buf
(
nullptr
);
...
...
libcaf_io/test/protocol_policy.cpp
View file @
c151505b
...
...
@@ -242,32 +242,24 @@ struct dummy_basp_newb : network::newb<new_basp_message> {
// nop
}
void
handle
(
new_basp_message
&
msg
)
override
{
CAF_MESSAGE
(
"handling new basp message = "
<<
to_string
(
msg
));
CAF_ASSERT
(
!
expected
.
empty
());
auto
&
e
=
expected
.
front
();
CAF_CHECK_EQUAL
(
msg
.
header
.
from
,
e
.
first
.
from
);
CAF_CHECK_EQUAL
(
msg
.
header
.
to
,
e
.
first
.
to
);
int
pl
;
binary_deserializer
bd
(
&
backend
(),
msg
.
payload
,
msg
.
payload_size
);
bd
(
pl
);
CAF_CHECK_EQUAL
(
pl
,
e
.
second
);
std
::
vector
<
char
>
payload
{
msg
.
payload
,
msg
.
payload
+
msg
.
payload_size
};
messages
.
emplace_back
(
msg
,
payload
);
messages
.
back
().
first
.
payload
=
messages
.
back
().
second
.
data
();
transport
->
receive_buffer
.
clear
();
expected
.
pop_front
();
}
behavior
make_behavior
()
override
{
set_default_handler
(
print_and_drop
);
return
{
// Must be implemented at the moment, will be cought by the broker in a
// later implementation.
[
=
](
atom_value
atm
,
uint32_t
id
)
{
CAF_MESSAGE
(
"timeout returned"
);
timeout_messages
.
emplace_back
(
atm
,
id
);
protocol
->
timeout
(
atm
,
id
);
[
=
](
new_basp_message
&
msg
)
{
CAF_MESSAGE
(
"handling new basp message = "
<<
to_string
(
msg
));
CAF_ASSERT
(
!
expected
.
empty
());
auto
&
e
=
expected
.
front
();
CAF_CHECK_EQUAL
(
msg
.
header
.
from
,
e
.
first
.
from
);
CAF_CHECK_EQUAL
(
msg
.
header
.
to
,
e
.
first
.
to
);
int
pl
;
binary_deserializer
bd
(
&
backend
(),
msg
.
payload
,
msg
.
payload_size
);
bd
(
pl
);
CAF_CHECK_EQUAL
(
pl
,
e
.
second
);
std
::
vector
<
char
>
payload
{
msg
.
payload
,
msg
.
payload
+
msg
.
payload_size
};
messages
.
emplace_back
(
msg
,
payload
);
messages
.
back
().
first
.
payload
=
messages
.
back
().
second
.
data
();
transport
->
receive_buffer
.
clear
();
expected
.
pop_front
();
},
[
=
](
send_atom
,
actor_id
sender
,
actor_id
receiver
,
int
payload
)
{
CAF_MESSAGE
(
"send: from = "
<<
sender
<<
" to = "
<<
receiver
...
...
@@ -485,12 +477,14 @@ CAF_TEST(timeouts) {
dummy
.
transport
->
max_consecutive_reads
=
1
;
auto
err
=
dummy
.
read_event
();
CAF_REQUIRE
(
!
err
);
CAF_CHECK
(
!
dummy
.
expected
.
empty
());
CAF_MESSAGE
(
"trigger waiting timeouts"
);
// Trigger timeout.
sched
.
trigger_timeout
();
// Handle received message.
exec_all
();
// Message handler will check if the expected message was received.
CAF_CHECK
(
dummy
.
expected
.
empty
());
}
CAF_TEST
(
message
ordering
)
{
...
...
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