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
a965a4c9
Unverified
Commit
a965a4c9
authored
Mar 18, 2020
by
Dominik Charousset
Committed by
GitHub
Mar 18, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1067
Fix unexpected responses to anon_send, close #1046
parents
b7d4f4be
a83e4230
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
59 additions
and
61 deletions
+59
-61
libcaf_core/caf/detail/profiled_send.hpp
libcaf_core/caf/detail/profiled_send.hpp
+18
-13
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
+37
-15
No files found.
libcaf_core/caf/detail/profiled_send.hpp
View file @
a965a4c9
...
...
@@ -31,32 +31,37 @@
namespace
caf
::
detail
{
template
<
class
Self
,
class
Se
nder
,
class
Handle
,
class
...
Ts
>
void
profiled_send
(
Self
*
self
,
Se
nder
&&
sender
,
const
Handle
&
receiver
,
template
<
class
Self
,
class
Se
lfHandle
,
class
Handle
,
class
...
Ts
>
void
profiled_send
(
Self
*
self
,
Se
lfHandle
&&
src
,
const
Handle
&
dst
,
message_id
msg_id
,
std
::
vector
<
strong_actor_ptr
>
stages
,
execution_unit
*
context
,
Ts
&&
...
xs
)
{
CAF_IGNORE_UNUSED
(
self
);
if
(
receiver
)
{
auto
element
=
make_mailbox_element
(
std
::
forward
<
Se
nder
>
(
sender
),
msg_id
,
if
(
dst
)
{
auto
element
=
make_mailbox_element
(
std
::
forward
<
Se
lfHandle
>
(
src
),
msg_id
,
std
::
move
(
stages
),
std
::
forward
<
Ts
>
(
xs
)...);
CAF_BEFORE_SENDING
(
self
,
*
element
);
receiver
->
enqueue
(
std
::
move
(
element
),
context
);
dst
->
enqueue
(
std
::
move
(
element
),
context
);
}
}
template
<
class
Self
,
class
Se
nder
,
class
Handle
,
class
...
Ts
>
void
profiled_send
(
Self
*
self
,
Se
nder
&&
sender
,
const
Handle
&
receiver
,
template
<
class
Self
,
class
Se
lfHandle
,
class
Handle
,
class
...
Ts
>
void
profiled_send
(
Self
*
self
,
Se
lfHandle
&&
src
,
const
Handle
&
dst
,
actor_clock
&
clock
,
actor_clock
::
time_point
timeout
,
message_id
msg_id
,
Ts
&&
...
xs
)
{
CAF_IGNORE_UNUSED
(
self
);
if
(
receiver
)
{
auto
element
=
make_mailbox_element
(
std
::
forward
<
Sender
>
(
sender
),
msg_id
,
if
(
dst
)
{
if
constexpr
(
std
::
is_same
<
Handle
,
group
>::
value
)
{
clock
.
schedule_message
(
timeout
,
dst
,
std
::
forward
<
SelfHandle
>
(
src
),
make_message
(
std
::
forward
<
Ts
>
(
xs
)...));
}
else
{
auto
element
=
make_mailbox_element
(
std
::
forward
<
SelfHandle
>
(
src
),
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 @
a965a4c9
...
...
@@ -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 @
a965a4c9
...
...
@@ -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
}};
...
...
@@ -41,6 +41,8 @@ struct fixture : test_coordinator_fixture<> {
group
grp
;
actor
testee
;
std
::
string
hello
=
"hello world"
;
fixture
()
{
grp
=
sys
.
groups
().
anonymous
();
testee
=
sys
.
spawn_in_group
(
grp
,
testee_impl
);
...
...
@@ -55,28 +57,48 @@ struct fixture : test_coordinator_fixture<> {
CAF_TEST_FIXTURE_SCOPE
(
sender_tests
,
fixture
)
CAF_TEST
(
delayed
actor
message
)
{
self
->
delayed_send
(
testee
,
seconds
(
1
),
"hello world"
);
CAF_TEST
(
delayed
actor
message
s
receive
responses
)
{
self
->
delayed_send
(
testee
,
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
}
CAF_TEST
(
delayed
group
message
)
{
self
->
delayed_send
(
grp
,
seconds
(
1
),
"hello world"
);
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
hello
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
self
->
scheduled_send
(
testee
,
self
->
clock
().
now
()
+
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
hello
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
}
CAF_TEST
(
scheduled
actor
message
)
{
self
->
scheduled_send
(
testee
,
self
->
clock
().
now
()
+
seconds
(
1
),
"hello world"
);
CAF_TEST
(
delayed
group
message
receive
responses
)
{
self
->
delayed_send
(
grp
,
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
hello
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
self
->
scheduled_send
(
grp
,
self
->
clock
().
now
()
+
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
hello
));
expect
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
}
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
);
expect
((
std
::
string
),
to
(
testee
).
with
(
hello
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
self
->
delayed_anon_send
(
testee
,
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
to
(
testee
).
with
(
hello
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
self
->
scheduled_anon_send
(
testee
,
self
->
clock
().
now
()
+
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
to
(
testee
).
with
(
hello
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
self
->
delayed_anon_send
(
grp
,
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
to
(
testee
).
with
(
hello
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
self
->
scheduled_anon_send
(
grp
,
self
->
clock
().
now
()
+
seconds
(
1
),
hello
);
sched
.
trigger_timeout
();
expect
((
std
::
string
),
from
(
self
).
to
(
testee
).
with
(
"hello world"
));
expect
((
std
::
string
),
to
(
testee
).
with
(
hello
));
disallow
((
std
::
string
),
from
(
testee
).
to
(
self
).
with
(
hello
));
}
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