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
983d14f8
Commit
983d14f8
authored
Jul 26, 2016
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add delayed_anon_send
parent
0ae125e9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
2 deletions
+43
-2
libcaf_core/caf/mixin/sender.hpp
libcaf_core/caf/mixin/sender.hpp
+19
-0
libcaf_core/test/simple_timeout.cpp
libcaf_core/test/simple_timeout.cpp
+24
-2
No files found.
libcaf_core/caf/mixin/sender.hpp
View file @
983d14f8
...
@@ -146,6 +146,25 @@ public:
...
@@ -146,6 +146,25 @@ public:
rtime
,
this
->
ctrl
(),
actor_cast
<
strong_actor_ptr
>
(
dest
),
rtime
,
this
->
ctrl
(),
actor_cast
<
strong_actor_ptr
>
(
dest
),
message_id
::
make
(
P
),
make_message
(
std
::
forward
<
Ts
>
(
xs
)...));
message_id
::
make
(
P
),
make_message
(
std
::
forward
<
Ts
>
(
xs
)...));
}
}
template
<
message_priority
P
=
message_priority
::
normal
,
class
Source
=
actor
,
class
Dest
=
actor
,
class
...
Ts
>
void
delayed_anon_send
(
const
Dest
&
dest
,
const
duration
&
rtime
,
Ts
&&
...
xs
)
{
static_assert
(
sizeof
...(
Ts
)
>
0
,
"no message to send"
);
using
token
=
detail
::
type_list
<
typename
detail
::
implicit_conversions
<
typename
std
::
decay
<
Ts
>::
type
>::
type
...
>
;
static_assert
(
actor_accepts_message
<
typename
signatures_of
<
Dest
>::
type
,
token
>::
value
,
"receiver does not accept given message"
);
this
->
system
().
scheduler
().
delayed_send
(
rtime
,
nullptr
,
actor_cast
<
strong_actor_ptr
>
(
dest
),
message_id
::
make
(
P
),
make_message
(
std
::
forward
<
Ts
>
(
xs
)...));
}
};
};
}
// namespace mixin
}
// namespace mixin
...
...
libcaf_core/test/simple_timeout.cpp
View file @
983d14f8
...
@@ -31,18 +31,36 @@ using namespace caf;
...
@@ -31,18 +31,36 @@ using namespace caf;
namespace
{
namespace
{
using
ms
=
std
::
chrono
::
milliseconds
;
using
reset_atom
=
atom_constant
<
atom
(
"reset"
)
>
;
using
reset_atom
=
atom_constant
<
atom
(
"reset"
)
>
;
using
timer
=
typed_actor
<
reacts_to
<
reset_atom
>>
;
using
timer
=
typed_actor
<
reacts_to
<
reset_atom
>>
;
timer
::
behavior_type
timer_impl
(
timer
::
pointer
self
)
{
timer
::
behavior_type
timer_impl
(
timer
::
pointer
self
)
{
auto
had_reset
=
std
::
make_shared
<
bool
>
(
false
);
auto
had_reset
=
std
::
make_shared
<
bool
>
(
false
);
self
->
delayed_send
(
self
,
std
::
chrono
::
milliseconds
(
100
),
reset_atom
::
value
);
self
->
delayed_send
(
self
,
ms
(
100
),
reset_atom
::
value
);
return
{
[
=
](
reset_atom
)
{
CAF_MESSAGE
(
"timer reset"
);
*
had_reset
=
true
;
},
after
(
ms
(
600
))
>>
[
=
]
{
CAF_MESSAGE
(
"timer expired"
);
CAF_REQUIRE
(
*
had_reset
);
self
->
quit
();
}
};
}
timer
::
behavior_type
timer_impl2
(
timer
::
pointer
self
)
{
auto
had_reset
=
std
::
make_shared
<
bool
>
(
false
);
self
->
delayed_anon_send
(
self
,
ms
(
100
),
reset_atom
::
value
);
return
{
return
{
[
=
](
reset_atom
)
{
[
=
](
reset_atom
)
{
CAF_MESSAGE
(
"timer reset"
);
CAF_MESSAGE
(
"timer reset"
);
*
had_reset
=
true
;
*
had_reset
=
true
;
},
},
after
(
std
::
chrono
::
millisecond
s
(
600
))
>>
[
=
]
{
after
(
m
s
(
600
))
>>
[
=
]
{
CAF_MESSAGE
(
"timer expired"
);
CAF_MESSAGE
(
"timer expired"
);
CAF_REQUIRE
(
*
had_reset
);
CAF_REQUIRE
(
*
had_reset
);
self
->
quit
();
self
->
quit
();
...
@@ -67,4 +85,8 @@ CAF_TEST(single_timeout) {
...
@@ -67,4 +85,8 @@ CAF_TEST(single_timeout) {
system
.
spawn
(
timer_impl
);
system
.
spawn
(
timer_impl
);
}
}
CAF_TEST
(
single_anon_timeout
)
{
system
.
spawn
(
timer_impl2
);
}
CAF_TEST_FIXTURE_SCOPE_END
()
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