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
96218a3b
Commit
96218a3b
authored
Sep 25, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
This seems to work for testing
parent
fbcedf80
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
8 deletions
+24
-8
libcaf_io/caf/io/newb.hpp
libcaf_io/caf/io/newb.hpp
+5
-5
libcaf_io/caf/policy/newb_reliability.hpp
libcaf_io/caf/policy/newb_reliability.hpp
+19
-3
No files found.
libcaf_io/caf/io/newb.hpp
View file @
96218a3b
...
@@ -375,8 +375,9 @@ struct newb : public extend<scheduled_actor, newb<Message>>::template
...
@@ -375,8 +375,9 @@ struct newb : public extend<scheduled_actor, newb<Message>>::template
template
<
class
Rep
=
int
,
class
Period
=
std
::
ratio
<
1
>
>
template
<
class
Rep
=
int
,
class
Period
=
std
::
ratio
<
1
>
>
void
set_timeout
(
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
,
void
set_timeout
(
std
::
chrono
::
duration
<
Rep
,
Period
>
timeout
,
atom_value
atm
,
uint32_t
id
)
{
atom_value
atm
,
uint32_t
id
)
{
auto
n
=
actor_clock
::
clock_type
::
now
();
//auto n = actor_clock::clock_type::now();
scheduled_actor
::
clock
().
set_ordinary_timeout
(
n
+
timeout
,
this
,
atm
,
id
);
//scheduled_actor::clock().set_ordinary_timeout(n + timeout, this, atm, id);
this
->
delayed_send
(
this
,
timeout
,
atm
,
id
);
}
}
/// Returns the `multiplexer` running this broker.
/// Returns the `multiplexer` running this broker.
...
@@ -541,9 +542,8 @@ struct newb_acceptor : public newb_base, public caf::ref_counted {
...
@@ -541,9 +542,8 @@ struct newb_acceptor : public newb_base, public caf::ref_counted {
writing_
(
false
),
writing_
(
false
),
args_
(
std
::
forward
<
Ts
>
(
xs
)...)
{
args_
(
std
::
forward
<
Ts
>
(
xs
)...)
{
// nop
// nop
if
(
sockfd
==
io
::
network
::
invalid_native_socket
)
{
if
(
sockfd
==
io
::
network
::
invalid_native_socket
)
std
::
cerr
<<
"Creating newb with invalid socket"
<<
std
::
endl
;
CAF_LOG_ERROR
(
"Creating newb with invalid socket"
);
}
}
}
newb_acceptor
(
const
newb_acceptor
&
other
)
=
delete
;
newb_acceptor
(
const
newb_acceptor
&
other
)
=
delete
;
...
...
libcaf_io/caf/policy/newb_reliability.hpp
View file @
96218a3b
...
@@ -21,6 +21,7 @@
...
@@ -21,6 +21,7 @@
#include <cstdint>
#include <cstdint>
#include <unordered_map>
#include <unordered_map>
#include <chrono>
#include <chrono>
#include <random>
#include "caf/binary_deserializer.hpp"
#include "caf/binary_deserializer.hpp"
#include "caf/binary_serializer.hpp"
#include "caf/binary_serializer.hpp"
...
@@ -31,7 +32,7 @@ namespace caf {
...
@@ -31,7 +32,7 @@ namespace caf {
namespace
policy
{
namespace
policy
{
using
id_type
=
uint16_t
;
using
id_type
=
uint16_t
;
using
reliability_atom
=
atom_constant
<
atom
(
"
ordering
"
)
>
;
using
reliability_atom
=
atom_constant
<
atom
(
"
reliabilit
"
)
>
;
struct
reliability_header
{
struct
reliability_header
{
id_type
id
;
id_type
id
;
...
@@ -56,10 +57,17 @@ struct reliability {
...
@@ -56,10 +57,17 @@ struct reliability {
using
result_type
=
typename
Next
::
result_type
;
using
result_type
=
typename
Next
::
result_type
;
id_type
id_write
=
0
;
id_type
id_write
=
0
;
// TODO: Make this configurable.
// TODO: Make this configurable.
std
::
chrono
::
milliseconds
retransmit_to
=
std
::
chrono
::
milliseconds
(
10
0
);
std
::
chrono
::
milliseconds
retransmit_to
=
std
::
chrono
::
milliseconds
(
4
0
);
io
::
newb
<
message_type
>*
parent
;
io
::
newb
<
message_type
>*
parent
;
Next
next
;
Next
next
;
std
::
unordered_map
<
id_type
,
io
::
byte_buffer
>
unacked
;
std
::
unordered_map
<
id_type
,
io
::
byte_buffer
>
unacked
;
std
::
random_device
rd
;
std
::
mt19937
mt
;
std
::
uniform_int_distribution
<
int
>
dist
;
reliability
()
:
mt
(
rd
()),
dist
(
0
,
9
)
{
// nop
}
void
init
(
io
::
newb
<
message_type
>*
n
)
{
void
init
(
io
::
newb
<
message_type
>*
n
)
{
parent
=
n
;
parent
=
n
;
...
@@ -72,10 +80,17 @@ struct reliability {
...
@@ -72,10 +80,17 @@ struct reliability {
reliability_header
hdr
;
reliability_header
hdr
;
binary_deserializer
bd
(
&
parent
->
backend
(),
bytes
,
count
);
binary_deserializer
bd
(
&
parent
->
backend
(),
bytes
,
count
);
bd
(
hdr
);
bd
(
hdr
);
auto
r
=
dist
(
mt
);
if
(
r
==
0
)
{
std
::
cerr
<<
"not this time: "
<<
hdr
.
id
<<
std
::
endl
;
return
none
;
}
if
(
hdr
.
is_ack
)
{
if
(
hdr
.
is_ack
)
{
// TODO: Cancel timeout.
// TODO: Cancel timeout.
unacked
.
erase
(
hdr
.
id
);
unacked
.
erase
(
hdr
.
id
);
std
::
cerr
<<
"got ack for "
<<
hdr
.
id
<<
std
::
endl
;
}
else
{
}
else
{
std
::
cerr
<<
"got header: "
<<
hdr
.
id
<<
std
::
endl
;
// Send ack.
// Send ack.
auto
&
buf
=
parent
->
wr_buf
();
auto
&
buf
=
parent
->
wr_buf
();
binary_serializer
bs
(
&
parent
->
backend
(),
buf
);
binary_serializer
bs
(
&
parent
->
backend
(),
buf
);
...
@@ -96,7 +111,7 @@ struct reliability {
...
@@ -96,7 +111,7 @@ struct reliability {
// Retransmit the packet.
// Retransmit the packet.
auto
&
packet
=
unacked
[
retransmit_id
];
auto
&
packet
=
unacked
[
retransmit_id
];
auto
&
buf
=
parent
->
wr_buf
();
auto
&
buf
=
parent
->
wr_buf
();
buf
.
insert
(
buf
.
begin
(),
packet
.
begin
(),
packet
.
end
());
buf
.
insert
(
buf
.
end
(),
packet
.
begin
(),
packet
.
end
());
parent
->
flush
();
parent
->
flush
();
parent
->
set_timeout
(
retransmit_to
,
reliability_atom
::
value
,
retransmit_id
);
parent
->
set_timeout
(
retransmit_to
,
reliability_atom
::
value
,
retransmit_id
);
}
}
...
@@ -121,6 +136,7 @@ struct reliability {
...
@@ -121,6 +136,7 @@ struct reliability {
// Add to unacked.
// Add to unacked.
unacked
.
emplace
(
id_write
,
unacked
.
emplace
(
id_write
,
io
::
byte_buffer
(
buf
.
begin
()
+
hstart
,
buf
.
end
()));
io
::
byte_buffer
(
buf
.
begin
()
+
hstart
,
buf
.
end
()));
std
::
cerr
<<
"awaiting ack for "
<<
id_write
<<
std
::
endl
;
id_write
+=
1
;
id_write
+=
1
;
}
}
};
};
...
...
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