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
1dec42fa
Commit
1dec42fa
authored
Feb 22, 2016
by
ufownl
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix thread sync issue in test `io_basp[_asio]`
parent
779d9171
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
13 additions
and
5 deletions
+13
-5
libcaf_io/src/basp_broker.cpp
libcaf_io/src/basp_broker.cpp
+1
-2
libcaf_io/src/test_multiplexer.cpp
libcaf_io/src/test_multiplexer.cpp
+9
-2
libcaf_io/test/basp.cpp
libcaf_io/test/basp.cpp
+3
-1
No files found.
libcaf_io/src/basp_broker.cpp
View file @
1dec42fa
...
...
@@ -327,7 +327,6 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
learned_new_node
(
nid
);
if
(
!
enable_automatic_connections
)
return
;
actor
bb
=
self
;
// a handle for our helper back to this BASP broker
// this member function gets only called once, after adding a new
// indirect connection to the routing table; hence, spawning
// our helper here exactly once and there is no need to track
...
...
@@ -353,7 +352,7 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
// gotcha! send scribe to our BASP broker
// to initiate handshake etc.
CAF_LOG_INFO
(
"connected directly:"
<<
CAF_ARG
(
addr
));
helper
->
send
(
bb
,
connect_atom
::
value
,
hdl
,
port
);
helper
->
send
(
s
,
connect_atom
::
value
,
hdl
,
port
);
return
;
}
catch
(...)
{
...
...
libcaf_io/src/test_multiplexer.cpp
View file @
1dec42fa
...
...
@@ -89,6 +89,7 @@ void test_multiplexer::assign_tcp_scribe(abstract_broker* ptr,
private:
test_multiplexer
*
mpx_
;
};
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
auto
sptr
=
make_counted
<
impl
>
(
ptr
,
hdl
,
this
);
impl_ptr
(
hdl
)
=
sptr
;
ptr
->
add_scribe
(
sptr
);
...
...
@@ -266,8 +267,8 @@ void test_multiplexer::accept_connection(accept_handle hdl) {
void
test_multiplexer
::
read_data
(
connection_handle
hdl
)
{
flush_runnables
();
scribe_data
&
sd
=
scribe_data_
[
hdl
];
if
(
sd
.
ptr
==
nullptr
)
throw
std
::
logic_error
(
"scribe data contains a nullptr"
);
while
(
sd
.
ptr
==
nullptr
)
exec_runnable
(
);
switch
(
sd
.
recv_conf
.
first
)
{
case
receive_policy_flag
:
:
exactly
:
while
(
sd
.
xbuf
.
size
()
>=
sd
.
recv_conf
.
second
)
{
...
...
@@ -302,12 +303,14 @@ void test_multiplexer::read_data(connection_handle hdl) {
void
test_multiplexer
::
virtual_send
(
connection_handle
hdl
,
const
buffer_type
&
buf
)
{
CAF_LOG_TRACE
(
CAF_ARG
(
hdl
));
auto
&
vb
=
virtual_network_buffer
(
hdl
);
vb
.
insert
(
vb
.
end
(),
buf
.
begin
(),
buf
.
end
());
read_data
(
hdl
);
}
void
test_multiplexer
::
exec_runnable
()
{
CAF_LOG_TRACE
(
""
);
resumable_ptr
ptr
;
{
// critical section
guard_type
guard
{
mx_
};
...
...
@@ -320,6 +323,7 @@ void test_multiplexer::exec_runnable() {
}
bool
test_multiplexer
::
try_exec_runnable
()
{
CAF_LOG_TRACE
(
""
);
resumable_ptr
ptr
;
{
// critical section
guard_type
guard
{
mx_
};
...
...
@@ -333,6 +337,7 @@ bool test_multiplexer::try_exec_runnable() {
}
void
test_multiplexer
::
flush_runnables
()
{
CAF_LOG_TRACE
(
""
);
// execute runnables in bursts, pick a small size to
// minimize time in the critical section
constexpr
size_t
max_runnable_count
=
8
;
...
...
@@ -357,6 +362,7 @@ void test_multiplexer::flush_runnables() {
void
test_multiplexer
::
exec_later
(
resumable
*
ptr
)
{
CAF_ASSERT
(
ptr
!=
nullptr
);
CAF_ASSERT
(
ptr
->
as_ref_counted_ptr
()
->
get_reference_count
()
>
0
);
CAF_LOG_TRACE
(
""
);
switch
(
ptr
->
subtype
())
{
case
resumable
:
:
io_actor
:
case
resumable
:
:
function_object
:
{
...
...
@@ -375,6 +381,7 @@ void test_multiplexer::exec_later(resumable* ptr) {
void
test_multiplexer
::
exec
(
resumable_ptr
&
ptr
)
{
CAF_ASSERT
(
ptr
!=
nullptr
);
CAF_ASSERT
(
ptr
->
as_ref_counted_ptr
()
->
get_reference_count
()
>
0
);
CAF_LOG_TRACE
(
""
);
switch
(
ptr
->
resume
(
this
,
1
))
{
case
resumable
:
:
resume_later
:
exec_later
(
ptr
.
get
());
...
...
libcaf_io/test/basp.cpp
View file @
1dec42fa
...
...
@@ -476,7 +476,9 @@ CAF_TEST(remote_address_and_port) {
connect_node
(
1
);
auto
mm
=
system
.
middleman
().
actor_handle
();
self
()
->
send
(
mm
,
get_atom
::
value
,
remote_node
(
1
));
mpx
()
->
exec_runnable
();
do
{
mpx
()
->
exec_runnable
();
}
while
(
!
self
()
->
has_next_message
());
self
()
->
receive
(
[
&
](
const
node_id
&
nid
,
const
std
::
string
&
addr
,
uint16_t
port
)
{
CAF_CHECK
(
nid
==
remote_node
(
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