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
97849853
Commit
97849853
authored
Jul 31, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Some cleanup to TCP newbs
parent
5456bca0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
30 deletions
+12
-30
libcaf_io/test/protocol_policy.cpp
libcaf_io/test/protocol_policy.cpp
+12
-30
No files found.
libcaf_io/test/protocol_policy.cpp
View file @
97849853
...
@@ -286,12 +286,8 @@ struct protocol_policy_base {
...
@@ -286,12 +286,8 @@ struct protocol_policy_base {
// nop
// nop
}
}
/// TODO: Come up with something better than a write here?
/// Write header into buffer. Use push back to append only.
virtual
void
write_header
(
byte_buffer
&
,
header_writer
*
)
=
0
;
virtual
void
write_header
(
byte_buffer
&
,
header_writer
*
)
=
0
;
//virtual size_t offset() const noexcept = 0;
virtual
void
prepare_for_sending
(
byte_buffer
&
,
size_t
,
size_t
)
=
0
;
virtual
void
prepare_for_sending
(
byte_buffer
&
,
size_t
,
size_t
)
=
0
;
};
};
...
@@ -322,12 +318,6 @@ struct protocol_policy_impl : protocol_policy<typename T::message_type> {
...
@@ -322,12 +318,6 @@ struct protocol_policy_impl : protocol_policy<typename T::message_type> {
return
impl
.
read
(
bytes
,
count
);
return
impl
.
read
(
bytes
,
count
);
}
}
/*
size_t offset() const noexcept override {
return T::offset;
}
*/
error
timeout
(
atom_value
atm
,
uint32_t
id
)
override
{
error
timeout
(
atom_value
atm
,
uint32_t
id
)
override
{
return
impl
.
timeout
(
atm
,
id
);
return
impl
.
timeout
(
atm
,
id
);
}
}
...
@@ -345,7 +335,9 @@ struct protocol_policy_impl : protocol_policy<typename T::message_type> {
...
@@ -345,7 +335,9 @@ struct protocol_policy_impl : protocol_policy<typename T::message_type> {
/// @relates newb
/// @relates newb
/// Returned by funtion wr_buf of newb.
/// Returned by funtion wr_buf of newb.
template
<
class
Message
>
struct
write_handle
{
struct
write_handle
{
newb
<
Message
>*
parent
;
protocol_policy_base
*
protocol
;
protocol_policy_base
*
protocol
;
byte_buffer
*
buf
;
byte_buffer
*
buf
;
size_t
header_start
;
size_t
header_start
;
...
@@ -355,6 +347,7 @@ struct write_handle {
...
@@ -355,6 +347,7 @@ struct write_handle {
// Can we calculate added bytes for datagram things?
// Can we calculate added bytes for datagram things?
auto
payload_size
=
buf
->
size
()
-
(
header_start
+
header_len
);
auto
payload_size
=
buf
->
size
()
-
(
header_start
+
header_len
);
protocol
->
prepare_for_sending
(
*
buf
,
header_start
,
payload_size
);
protocol
->
prepare_for_sending
(
*
buf
,
header_start
,
payload_size
);
parent
->
flush
();
}
}
};
};
...
@@ -498,7 +491,7 @@ struct newb : public extend<scheduled_actor, newb<Message>>::template
...
@@ -498,7 +491,7 @@ struct newb : public extend<scheduled_actor, newb<Message>>::template
passivate
();
passivate
();
}
}
write_handle
wr_buf
(
header_writer
*
hw
)
{
write_handle
<
Message
>
wr_buf
(
header_writer
*
hw
)
{
// TODO: We somehow need to tell the transport policy how much we've
// TODO: We somehow need to tell the transport policy how much we've
// written to enable it to split the buffer into datagrams.
// written to enable it to split the buffer into datagrams.
auto
&
buf
=
transport
->
wr_buf
();
auto
&
buf
=
transport
->
wr_buf
();
...
@@ -507,7 +500,7 @@ struct newb : public extend<scheduled_actor, newb<Message>>::template
...
@@ -507,7 +500,7 @@ struct newb : public extend<scheduled_actor, newb<Message>>::template
auto
hlen
=
buf
.
size
()
-
hstart
;
auto
hlen
=
buf
.
size
()
-
hstart
;
CAF_MESSAGE
(
"returning write buffer starting at "
<<
hstart
<<
" and "
CAF_MESSAGE
(
"returning write buffer starting at "
<<
hstart
<<
" and "
<<
hlen
<<
" bytes of header"
);
<<
hlen
<<
" bytes of header"
);
return
{
protocol
.
get
(),
&
buf
,
hstart
,
hlen
};
return
{
this
,
protocol
.
get
(),
&
buf
,
hstart
,
hlen
};
}
}
void
flush
()
{
void
flush
()
{
...
@@ -1073,7 +1066,7 @@ struct tcp_transport_policy : public transport_policy {
...
@@ -1073,7 +1066,7 @@ struct tcp_transport_policy : public transport_policy {
}
}
byte_buffer
&
wr_buf
()
{
byte_buffer
&
wr_buf
()
{
return
send
_buffer
;
return
offline
_buffer
;
}
}
void
flush
(
network
::
event_handler
*
parent
)
override
{
void
flush
(
network
::
event_handler
*
parent
)
override
{
...
@@ -1109,12 +1102,6 @@ struct tcp_protocol_policy : protocol_policy<typename T::message_type> {
...
@@ -1109,12 +1102,6 @@ struct tcp_protocol_policy : protocol_policy<typename T::message_type> {
return
impl
.
read
(
bytes
,
count
);
return
impl
.
read
(
bytes
,
count
);
}
}
/*
size_t offset() const noexcept override {
return T::offset;
}
*/
error
timeout
(
atom_value
atm
,
uint32_t
id
)
override
{
error
timeout
(
atom_value
atm
,
uint32_t
id
)
override
{
return
impl
.
timeout
(
atm
,
id
);
return
impl
.
timeout
(
atm
,
id
);
}
}
...
@@ -1159,16 +1146,11 @@ struct tcp_basp_newb : newb<new_tcp_basp_message> {
...
@@ -1159,16 +1146,11 @@ struct tcp_basp_newb : newb<new_tcp_basp_message> {
bs
(
tcp_basp_header
{
0
,
sender
,
receiver
});
bs
(
tcp_basp_header
{
0
,
sender
,
receiver
});
return
none
;
return
none
;
});
});
{
auto
whdl
=
wr_buf
(
&
hw
);
// TODO: Need a better idea how to do this ... Maybe pass the write
CAF_CHECK
(
whdl
.
buf
!=
nullptr
);
// handle to flush which then calls `perpare_for_sending`?
CAF_CHECK
(
whdl
.
protocol
!=
nullptr
);
auto
whdl
=
wr_buf
(
&
hw
);
binary_serializer
bs
(
&
backend
(),
*
whdl
.
buf
);
CAF_CHECK
(
whdl
.
buf
!=
nullptr
);
bs
(
payload
);
CAF_CHECK
(
whdl
.
protocol
!=
nullptr
);
binary_serializer
bs
(
&
backend
(),
*
whdl
.
buf
);
bs
(
payload
);
}
flush
();
},
},
[
=
](
quit_atom
)
{
[
=
](
quit_atom
)
{
CAF_MESSAGE
(
"newb actor shutting down"
);
CAF_MESSAGE
(
"newb actor shutting down"
);
...
@@ -1627,7 +1609,7 @@ CAF_TEST_FIXTURE_SCOPE_END()
...
@@ -1627,7 +1609,7 @@ CAF_TEST_FIXTURE_SCOPE_END()
CAF_TEST_FIXTURE_SCOPE
(
tcp_newbs
,
fixture
)
CAF_TEST_FIXTURE_SCOPE
(
tcp_newbs
,
fixture
)
CAF_TEST
(
accept
test
)
{
CAF_TEST
(
tcp
basp
newb
)
{
scoped_actor
main_actor
{
sys
};
scoped_actor
main_actor
{
sys
};
actor
newb_actor
;
actor
newb_actor
;
auto
testing
=
[
&
](
stateful_broker
<
test_broker_state
>*
self
,
auto
testing
=
[
&
](
stateful_broker
<
test_broker_state
>*
self
,
...
...
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