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
69c027dc
Commit
69c027dc
authored
Dec 05, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Let acceptor decide if children start reading
parent
8c04c830
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
9 deletions
+15
-9
libcaf_io/caf/io/newb.hpp
libcaf_io/caf/io/newb.hpp
+8
-6
libcaf_io/caf/policy/accept.hpp
libcaf_io/caf/policy/accept.hpp
+4
-0
libcaf_io/test/newb.cpp
libcaf_io/test/newb.cpp
+3
-3
No files found.
libcaf_io/caf/io/newb.hpp
View file @
69c027dc
...
...
@@ -172,9 +172,6 @@ struct newb : public network::newb_base {
// as an event handler.
if
(
!
reading_
&&
!
writing_
)
intrusive_ptr_add_ref
(
this
->
ctrl
());
start_reading
();
if
(
trans
)
trans
->
prepare_next_read
(
this
);
}
void
stop
()
override
{
...
...
@@ -219,6 +216,8 @@ struct newb : public network::newb_base {
if
(
!
reading_
)
{
event_handler
::
activate
();
reading_
=
true
;
if
(
trans
)
trans
->
prepare_next_read
(
this
);
}
}
...
...
@@ -379,7 +378,7 @@ template <class Protocol, spawn_options Os = no_spawn_options, class F,
class
...
Ts
>
typename
infer_handle_from_fun
<
F
>::
type
spawn_newb
(
actor_system
&
sys
,
F
fun
,
policy
::
transport_ptr
transport
,
network
::
native_socket
sockfd
,
Ts
&&
...
xs
)
{
network
::
native_socket
sockfd
,
bool
start_reading
,
Ts
&&
...
xs
)
{
using
impl
=
typename
infer_handle_from_fun
<
F
>::
impl
;
using
first
=
first_argument_type
<
F
>
;
using
message
=
typename
std
::
remove_pointer
<
first
>::
type
::
message_type
;
...
...
@@ -400,6 +399,8 @@ spawn_newb(actor_system& sys, F fun, policy::transport_ptr transport,
auto
&
ref
=
dynamic_cast
<
newb
<
message
>&>
(
*
ptr
);
// Start the event handler.
ref
.
start
();
if
(
start_reading
)
ref
.
start_reading
();
return
res
;
}
...
...
@@ -411,7 +412,7 @@ spawn_client(actor_system& sys, F fun, policy::transport_ptr transport,
expected
<
network
::
native_socket
>
esock
=
transport
->
connect
(
host
,
port
);
if
(
!
esock
)
return
std
::
move
(
esock
.
error
());
return
spawn_newb
<
Protocol
>
(
sys
,
fun
,
std
::
move
(
transport
),
*
esock
,
return
spawn_newb
<
Protocol
>
(
sys
,
fun
,
std
::
move
(
transport
),
*
esock
,
true
,
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -581,7 +582,8 @@ struct newb_acceptor : network::newb_base {
io
::
spawn_newb
<
Protocol
,
no_spawn_options
,
Fun
,
Ts
...
>
,
detail
::
get_indices
(
args_
),
args_
,
this
->
backend
().
system
(),
fun_
,
std
::
move
(
pol
),
sockfd
fun_
,
std
::
move
(
pol
),
sockfd
,
accept_pol
->
add_children_to_loop
()
);
link_to
(
n
);
children_
.
push_back
(
n
);
...
...
libcaf_io/caf/policy/accept.hpp
View file @
69c027dc
...
...
@@ -46,6 +46,10 @@ struct accept {
// nop
}
virtual
bool
add_children_to_loop
()
{
return
true
;
}
virtual
expected
<
io
::
network
::
native_socket
>
create_socket
(
uint16_t
port
,
const
char
*
host
,
bool
reuse
=
false
)
=
0
;
...
...
libcaf_io/test/newb.cpp
View file @
69c027dc
...
...
@@ -177,7 +177,7 @@ struct fixture {
// Create newb.
transport_ptr
transport
{
new
dummy_transport
};
test_newb
=
spawn_newb
<
protocol_t
>
(
sys
,
dummy_broker
,
std
::
move
(
transport
),
esock
->
first
);
esock
->
first
,
true
);
}
~
fixture
()
{
...
...
@@ -258,7 +258,7 @@ CAF_TEST(spawn newb) {
CAF_REQUIRE
(
esock
);
transport_ptr
transport
{
new
dummy_transport
};
auto
n
=
spawn_newb
<
protocol_t
>
(
sys
,
my_newb
,
std
::
move
(
transport
),
esock
->
first
);
esock
->
first
,
true
);
exec_all
();
CAF_MESSAGE
(
"send test message"
);
self
->
send
(
n
,
3
);
...
...
@@ -288,7 +288,7 @@ CAF_TEST(spawn stateful newb) {
CAF_REQUIRE
(
esock
);
transport_ptr
transport
{
new
dummy_transport
};
auto
n
=
spawn_newb
<
protocol_t
>
(
sys
,
my_newb
,
std
::
move
(
transport
),
esock
->
first
);
esock
->
first
,
true
);
exec_all
();
CAF_MESSAGE
(
"set value in state"
);
self
->
send
(
n
,
set_atom
::
value
,
3
);
...
...
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