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
0777157c
Commit
0777157c
authored
Mar 13, 2020
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix unexpected responses to anon_send, close #1046
parent
2d78dbd6
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
48 additions
and
50 deletions
+48
-50
libcaf_core/caf/detail/profiled_send.hpp
libcaf_core/caf/detail/profiled_send.hpp
+12
-7
libcaf_core/caf/mixin/sender.hpp
libcaf_core/caf/mixin/sender.hpp
+4
-33
libcaf_core/test/mixin/sender.cpp
libcaf_core/test/mixin/sender.cpp
+32
-10
No files found.
libcaf_core/caf/detail/profiled_send.hpp
View file @
0777157c
...
...
@@ -46,17 +46,22 @@ void profiled_send(Self* self, Sender&& sender, const Handle& receiver,
}
template
<
class
Self
,
class
Sender
,
class
Handle
,
class
...
Ts
>
void
profiled_send
(
Self
*
self
,
Sender
&&
sender
,
const
Handle
&
receiver
,
void
profiled_send
(
Self
*
self
,
Sender
&&
sender
,
const
Handle
&
dst
,
actor_clock
&
clock
,
actor_clock
::
time_point
timeout
,
message_id
msg_id
,
Ts
&&
...
xs
)
{
CAF_IGNORE_UNUSED
(
self
);
if
(
receiver
)
{
if
(
dst
)
{
if
constexpr
(
std
::
is_same
<
Handle
,
group
>::
value
)
{
clock
.
schedule_message
(
timeout
,
dst
,
std
::
forward
<
Sender
>
(
sender
),
make_message
(
std
::
forward
<
Ts
>
(
xs
)...));
}
else
{
auto
element
=
make_mailbox_element
(
std
::
forward
<
Sender
>
(
sender
),
msg_id
,
no_stages
,
std
::
forward
<
Ts
>
(
xs
)...);
CAF_BEFORE_SENDING_SCHEDULED
(
self
,
timeout
,
*
element
);
clock
.
schedule_message
(
timeout
,
actor_cast
<
strong_actor_ptr
>
(
receiver
),
clock
.
schedule_message
(
timeout
,
actor_cast
<
strong_actor_ptr
>
(
dst
),
std
::
move
(
element
));
}
}
}
}
// namespace caf::detail
libcaf_core/caf/mixin/sender.hpp
View file @
0777157c
...
...
@@ -94,7 +94,7 @@ public:
static_assert
(
response_type_unbox
<
signatures_of_t
<
Dest
>
,
token
>::
valid
,
"receiver does not accept given message"
);
auto
self
=
dptr
();
detail
::
profiled_send
(
self
,
self
->
ctrl
()
,
dest
,
make_message_id
(
P
),
{},
detail
::
profiled_send
(
self
,
nullptr
,
dest
,
make_message_id
(
P
),
{},
self
->
context
(),
std
::
forward
<
Ts
>
(
xs
)...);
}
...
...
@@ -172,8 +172,8 @@ public:
detail
::
type_list
<
detail
::
strip_and_convert_t
<
Ts
>
...
>
args_token
;
type_check
(
dest
,
args_token
);
auto
self
=
dptr
();
detail
::
profiled_send
(
self
,
self
->
ctrl
(),
dest
,
self
->
system
().
clock
()
,
timeout
,
make_message_id
(
P
),
std
::
forward
<
Ts
>
(
xs
)...);
detail
::
profiled_send
(
self
,
nullptr
,
dest
,
self
->
system
().
clock
(),
timeout
,
make_message_id
(
P
),
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
message_priority
P
=
message_priority
::
normal
,
class
Dest
=
actor
,
...
...
@@ -187,40 +187,11 @@ public:
auto
self
=
dptr
();
auto
&
clock
=
self
->
system
().
clock
();
auto
timeout
=
clock
.
now
()
+
rel_timeout
;
detail
::
profiled_send
(
self
,
self
->
ctrl
()
,
dest
,
clock
,
timeout
,
detail
::
profiled_send
(
self
,
nullptr
,
dest
,
clock
,
timeout
,
make_message_id
(
P
),
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
Rep
=
int
,
class
Period
=
std
::
ratio
<
1
>,
class
...
Ts
>
void
delayed_anon_send
(
const
group
&
dest
,
std
::
chrono
::
duration
<
Rep
,
Period
>
rtime
,
Ts
&&
...
xs
)
{
delayed_anon_send_impl
(
dest
,
rtime
,
std
::
forward
<
Ts
>
(
xs
)...);
}
private:
template
<
class
Dest
,
class
...
Ts
>
void
scheduled_send_impl
(
message_id
mid
,
const
Dest
&
dest
,
actor_clock
&
clock
,
actor_clock
::
time_point
timeout
,
Ts
&&
...
xs
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
detail
::
type_list
<
detail
::
strip_and_convert_t
<
Ts
>
...
>
args_token
;
type_check
(
dest
,
args_token
);
auto
self
=
dptr
();
detail
::
profiled_send
(
self
,
self
->
ctrl
(),
dest
,
clock
,
timeout
,
mid
,
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
Dest
,
class
...
Ts
>
void
scheduled_anon_send_impl
(
message_id
mid
,
const
Dest
&
dest
,
actor_clock
&
clock
,
actor_clock
::
time_point
timeout
,
Ts
&&
...
xs
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
detail
::
type_list
<
detail
::
strip_and_convert_t
<
Ts
>
...
>
args_token
;
type_check
(
dest
,
args_token
);
auto
self
=
dptr
();
detail
::
profiled_send
(
self
,
nullptr
,
dest
,
clock
,
timeout
,
mid
,
std
::
forward
<
Ts
>
(
xs
)...);
}
template
<
class
Dest
,
class
ArgTypes
>
static
void
type_check
(
const
Dest
&
,
ArgTypes
)
{
static_assert
(
!
statically_typed
<
Subtype
>
()
||
statically_typed
<
Dest
>
(),
...
...
libcaf_core/test/mixin/sender.cpp
View file @
0777157c
...
...
@@ -31,7 +31,7 @@ using std::chrono::seconds;
namespace
{
behavior
testee_impl
(
event_based_actor
*
self
)
{
self
->
set_default_handler
(
drop
);
self
->
set_default_handler
(
reflect
);
return
{[]
{
// nop
}};
...
...
@@ -55,28 +55,50 @@ struct fixture : test_coordinator_fixture<> {
CAF_TEST_FIXTURE_SCOPE
(
sender_tests
,
fixture
)
CAF_TEST
(
delayed
actor
message
)
{
CAF_TEST
(
delayed
actor
message
s
receive
responses
)
{
self
->
delayed_send
(
testee
,
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
self
->
scheduled_send
(
testee
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
}
CAF_TEST
(
delayed
group
message
)
{
CAF_TEST
(
delayed
group
message
receive
responses
)
{
self
->
delayed_send
(
grp
,
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
}
CAF_TEST
(
scheduled
actor
message
)
{
self
->
scheduled_send
(
testee
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
self
->
scheduled_send
(
grp
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
}
CAF_TEST
(
scheduled
group
message
)
{
self
->
scheduled_send
(
grp
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
CAF_TEST
(
anonymous
messages
receive
no
response
)
{
self
->
anon_send
(
testee
,
"hello world"
);
expect
((
std
::
string
),
to
(
testee
).
with
(
"hello world"
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
self
->
delayed_anon_send
(
testee
,
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
to
(
testee
).
with
(
"hello world"
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
self
->
scheduled_anon_send
(
testee
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
to
(
testee
).
with
(
"hello world"
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
self
->
delayed_anon_send
(
grp
,
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
to
(
testee
).
with
(
"hello world"
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
self
->
scheduled_anon_send
(
grp
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
to
(
testee
).
with
(
"hello world"
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
"hello world"
));
}
CAF_TEST_FIXTURE_SCOPE_END
()
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