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
ef96bb17
Commit
ef96bb17
authored
Oct 07, 2018
by
Joseph Noir
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add non-overriding receive timouts to actor clock
parent
5418edea
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
54 additions
and
7 deletions
+54
-7
libcaf_core/caf/actor_clock.hpp
libcaf_core/caf/actor_clock.hpp
+5
-1
libcaf_core/caf/detail/simple_actor_clock.hpp
libcaf_core/caf/detail/simple_actor_clock.hpp
+4
-1
libcaf_core/src/simple_actor_clock.cpp
libcaf_core/src/simple_actor_clock.cpp
+9
-1
libcaf_core/test/actor_clock.cpp
libcaf_core/test/actor_clock.cpp
+36
-4
No files found.
libcaf_core/caf/actor_clock.hpp
View file @
ef96bb17
...
@@ -56,7 +56,11 @@ public:
...
@@ -56,7 +56,11 @@ public:
/// Schedules a `timeout_msg` for `self` at time point `t`, overriding any
/// Schedules a `timeout_msg` for `self` at time point `t`, overriding any
/// previous receive timeout.
/// previous receive timeout.
virtual
void
set_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
virtual
void
set_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
atom_value
type
,
uint64_t
id
)
=
0
;
atom_value
type
,
uint64_t
id
)
=
0
;
/// Schedules a `timeout_msg` for `self` at time point `t`.
virtual
void
add_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
atom_value
type
,
uint64_t
id
)
=
0
;
/// Schedules a `sec::request_timeout` for `self` at time point `t`.
/// Schedules a `sec::request_timeout` for `self` at time point `t`.
virtual
void
set_request_timeout
(
time_point
t
,
abstract_actor
*
self
,
virtual
void
set_request_timeout
(
time_point
t
,
abstract_actor
*
self
,
...
...
libcaf_core/caf/detail/simple_actor_clock.hpp
View file @
ef96bb17
...
@@ -91,7 +91,10 @@ public:
...
@@ -91,7 +91,10 @@ public:
};
};
void
set_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
void
set_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
atom_value
type
,
uint64_t
id
)
override
;
atom_value
type
,
uint64_t
id
)
override
;
void
add_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
atom_value
type
,
uint64_t
id
)
override
;
void
set_request_timeout
(
time_point
t
,
abstract_actor
*
self
,
void
set_request_timeout
(
time_point
t
,
abstract_actor
*
self
,
message_id
id
)
override
;
message_id
id
)
override
;
...
...
libcaf_core/src/simple_actor_clock.cpp
View file @
ef96bb17
...
@@ -62,7 +62,7 @@ void simple_actor_clock::visitor::operator()(group_msg& x) {
...
@@ -62,7 +62,7 @@ void simple_actor_clock::visitor::operator()(group_msg& x) {
}
}
void
simple_actor_clock
::
set_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
void
simple_actor_clock
::
set_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
atom_value
type
,
uint64_t
id
)
{
atom_value
type
,
uint64_t
id
)
{
ordinary_predicate
pred
{
type
};
ordinary_predicate
pred
{
type
};
auto
i
=
lookup
(
self
,
pred
);
auto
i
=
lookup
(
self
,
pred
);
auto
sptr
=
actor_cast
<
strong_actor_ptr
>
(
self
);
auto
sptr
=
actor_cast
<
strong_actor_ptr
>
(
self
);
...
@@ -76,6 +76,14 @@ void simple_actor_clock::set_ordinary_timeout(time_point t, abstract_actor* self
...
@@ -76,6 +76,14 @@ void simple_actor_clock::set_ordinary_timeout(time_point t, abstract_actor* self
}
}
}
}
void
simple_actor_clock
::
add_ordinary_timeout
(
time_point
t
,
abstract_actor
*
self
,
atom_value
type
,
uint64_t
id
)
{
auto
sptr
=
actor_cast
<
strong_actor_ptr
>
(
self
);
ordinary_timeout
tmp
{
std
::
move
(
sptr
),
type
,
id
};
auto
j
=
schedule_
.
emplace
(
t
,
std
::
move
(
tmp
));
actor_lookup_
.
emplace
(
self
,
j
);
}
void
simple_actor_clock
::
set_request_timeout
(
time_point
t
,
abstract_actor
*
self
,
void
simple_actor_clock
::
set_request_timeout
(
time_point
t
,
abstract_actor
*
self
,
message_id
id
)
{
message_id
id
)
{
request_predicate
pred
{
id
};
request_predicate
pred
{
id
};
...
...
libcaf_core/test/actor_clock.cpp
View file @
ef96bb17
...
@@ -47,6 +47,11 @@ behavior testee(stateful_actor<testee_state, raw_event_based_actor>* self,
...
@@ -47,6 +47,11 @@ behavior testee(stateful_actor<testee_state, raw_event_based_actor>* self,
t
->
set_ordinary_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
t
->
set_ordinary_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
},
},
[
=
](
add_atom
)
{
[
=
](
add_atom
)
{
auto
n
=
t
->
now
()
+
seconds
(
10
);
self
->
state
.
timeout_id
+=
1
;
t
->
add_ordinary_timeout
(
n
,
self
,
atom
(
""
),
self
->
state
.
timeout_id
);
},
[
=
](
put_atom
)
{
auto
n
=
t
->
now
()
+
seconds
(
10
);
auto
n
=
t
->
now
()
+
seconds
(
10
);
self
->
state
.
timeout_id
+=
1
;
self
->
state
.
timeout_id
+=
1
;
auto
mid
=
make_message_id
(
self
->
state
.
timeout_id
).
response_id
();
auto
mid
=
make_message_id
(
self
->
state
.
timeout_id
).
response_id
();
...
@@ -124,12 +129,39 @@ CAF_TEST(override_receive_timeout) {
...
@@ -124,12 +129,39 @@ CAF_TEST(override_receive_timeout) {
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
43
}));
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
43
}));
}
}
CAF_TEST
(
single_request
_timeout
)
{
CAF_TEST
(
add_receive
_timeout
)
{
// Have AUT call t.set_re
quest
_timeout().
// Have AUT call t.set_re
ceive
_timeout().
self
->
send
(
aut
,
add_atom
::
value
);
self
->
send
(
aut
,
add_atom
::
value
);
expect
((
add_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
expect
((
add_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time just a little bit.
t
.
advance_time
(
seconds
(
5
));
// Have AUT call t.set_timeout() again.
self
->
send
(
aut
,
add_atom
::
value
);
expect
((
add_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
5
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Have AUT receive the timeout.
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
42
}));
// Advance time to send second timeout message.
t
.
advance_time
(
seconds
(
5
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
0u
);
// Have AUT receive the timeout.
expect
((
timeout_msg
),
from
(
aut
).
to
(
aut
).
with
(
tid
{
43
}));
}
CAF_TEST
(
single_request_timeout
)
{
// Have AUT call t.set_request_timeout().
self
->
send
(
aut
,
put_atom
::
value
);
expect
((
put_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
1u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
1u
);
// Advance time to send timeout message.
// Advance time to send timeout message.
t
.
advance_time
(
seconds
(
10
));
t
.
advance_time
(
seconds
(
10
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
0u
);
...
@@ -147,8 +179,8 @@ CAF_TEST(mixed_receive_and_request_timeouts) {
...
@@ -147,8 +179,8 @@ CAF_TEST(mixed_receive_and_request_timeouts) {
// Cause the request timeout to arrive later.
// Cause the request timeout to arrive later.
t
.
advance_time
(
seconds
(
5
));
t
.
advance_time
(
seconds
(
5
));
// Have AUT call t.set_request_timeout().
// Have AUT call t.set_request_timeout().
self
->
send
(
aut
,
add
_atom
::
value
);
self
->
send
(
aut
,
put
_atom
::
value
);
expect
((
add
_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
expect
((
put
_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
schedule
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
CAF_CHECK_EQUAL
(
t
.
actor_lookup
().
size
(),
2u
);
// Advance time to send receive timeout message.
// Advance time to send receive timeout message.
...
...
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