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
a1fd7896
Commit
a1fd7896
authored
Sep 29, 2021
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Integrate review feedback
parent
daff3591
Changes
9
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
43 additions
and
44 deletions
+43
-44
libcaf_core/caf/abstract_actor.hpp
libcaf_core/caf/abstract_actor.hpp
+8
-0
libcaf_core/caf/abstract_channel.hpp
libcaf_core/caf/abstract_channel.hpp
+4
-0
libcaf_core/caf/action.hpp
libcaf_core/caf/action.hpp
+2
-0
libcaf_core/caf/actor_clock.hpp
libcaf_core/caf/actor_clock.hpp
+18
-18
libcaf_core/caf/disposable.hpp
libcaf_core/caf/disposable.hpp
+1
-1
libcaf_core/caf/scheduled_actor.hpp
libcaf_core/caf/scheduled_actor.hpp
+3
-3
libcaf_core/src/detail/thread_safe_actor_clock.cpp
libcaf_core/src/detail/thread_safe_actor_clock.cpp
+2
-1
libcaf_core/test/actor_clock.cpp
libcaf_core/test/actor_clock.cpp
+5
-5
libcaf_core/test/detached_actors.cpp
libcaf_core/test/detached_actors.cpp
+0
-16
No files found.
libcaf_core/caf/abstract_actor.hpp
View file @
a1fd7896
...
...
@@ -57,6 +57,14 @@ public:
/// Enqueues a new message wrapped in a `mailbox_element` to the actor.
/// This `enqueue` variant allows to define forwarding chains.
/// @returns `true` if the message has added to the mailbox, `false`
/// otherwise. In the latter case, the actor terminated and the
/// message has been dropped. Once this function returns `false`, it
/// returns `false` for all future invocations.
/// @note The returned value is purely informational and may be used to
/// discard actor handles early. Messages may still get dropped later
/// even if this function returns `true`. In particular when dealing
/// with remote actors.
virtual
bool
enqueue
(
mailbox_element_ptr
what
,
execution_unit
*
host
)
=
0
;
/// Attaches `ptr` to this actor. The actor will call `ptr->detach(...)` on
...
...
libcaf_core/caf/abstract_channel.hpp
View file @
a1fd7896
...
...
@@ -23,6 +23,10 @@ public:
virtual
~
abstract_channel
();
/// Enqueues a new message without forwarding stack to the channel.
/// @returns `true` if the message has been dispatches successful, `false`
/// otherwise. In the latter case, the channel has been closed and
/// the message has been dropped. Once this function returns `false`,
/// it returns `false` for all future invocations.
virtual
bool
enqueue
(
strong_actor_ptr
sender
,
message_id
mid
,
message
content
,
execution_unit
*
host
=
nullptr
)
=
0
;
...
...
libcaf_core/caf/action.hpp
View file @
a1fd7896
...
...
@@ -227,6 +227,8 @@ namespace caf {
/// `action::state::waiting`.
template
<
class
F
>
action
make_action
(
F
f
,
action
::
state
init_state
=
action
::
state
::
scheduled
)
{
CAF_ASSERT
(
init_state
==
action
::
state
::
scheduled
||
init_state
==
action
::
state
::
waiting
);
using
impl_t
=
detail
::
default_action_impl
<
F
>
;
return
action
{
make_counted
<
impl_t
>
(
std
::
move
(
f
),
init_state
)};
}
...
...
libcaf_core/caf/actor_clock.hpp
View file @
a1fd7896
...
...
@@ -67,39 +67,39 @@ public:
=
0
;
/// Schedules an action for execution by an actor at a later time.
/// @param t The local time at which the action
gets enqueued to the mailbox
///
of the worker
.
/// @param t The local time at which the action
should get enqueued to the
///
mailbox of the target
.
/// @param f The action to schedule.
/// @param
worker
The actor that should run the action.
disposable
schedule
(
time_point
t
,
action
f
,
strong_actor_ptr
worker
);
/// @param
target
The actor that should run the action.
disposable
schedule
(
time_point
t
,
action
f
,
strong_actor_ptr
target
);
/// Schedules an action for periodic execution by an actor.
/// @param first_run The local time at which the action
gets enqueued to the
///
mailbox of the worker
for the first time.
/// @param first_run The local time at which the action
should get enqueued to
///
the mailbox of the target
for the first time.
/// @param f The action to schedule.
/// @param
worker
The actor that should run the action.
/// @param
target
The actor that should run the action.
/// @param period The time to wait between two messages to the actor.
/// @param policy The strategy for dealing with a stalling
worker
.
/// @param policy The strategy for dealing with a stalling
target
.
disposable
schedule_periodically
(
time_point
first_run
,
action
f
,
strong_actor_ptr
worker
,
strong_actor_ptr
target
,
duration_type
period
,
stall_policy
policy
);
/// Schedules an action for execution by an actor at a later time.
/// @param
worker
The actor that should run the action.
/// @param
target
The actor that should run the action.
/// @param f The action to schedule.
/// @param t The local time at which the action
gets enqueued to the mailbox
///
of the worker
.
disposable
schedule
(
time_point
t
,
action
f
,
weak_actor_ptr
worker
);
/// @param t The local time at which the action
should get enqueued to the
///
mailbox of the target
.
disposable
schedule
(
time_point
t
,
action
f
,
weak_actor_ptr
target
);
/// Schedules an action for periodic execution by an actor.
/// @param
worker The actor that should run the action.
///
@param policy The strategy for dealing with a stalling worker
.
/// @param
first_run The local time at which the action should get enqueued to
///
the mailbox of the target for the first time
.
/// @param f The action to schedule.
/// @param first_run The local time at which the action gets enqueued to the
/// mailbox of the worker for the first time.
/// @param target The actor that should run the action.
/// @param period The time to wait between two messages to the actor.
/// @param policy The strategy for dealing with a stalling target.
disposable
schedule_periodically
(
time_point
first_run
,
action
f
,
weak_actor_ptr
worker
,
duration_type
period
,
weak_actor_ptr
target
,
duration_type
period
,
stall_policy
policy
);
/// Schedules an arbitrary message to `receiver` for time point `t`.
...
...
libcaf_core/caf/disposable.hpp
View file @
a1fd7896
...
...
@@ -50,7 +50,7 @@ public:
disposable
&
operator
=
(
disposable
&&
)
noexcept
=
default
;
disposable
&
operator
=
(
const
disposable
&
)
noexcept
=
default
;
/// Combines multiple disposable into a single disposable. The new disposable
/// Combines multiple disposable
s
into a single disposable. The new disposable
/// is disposed if all of its elements are disposed. Disposing the composite
/// disposes all elements individually.
static
disposable
make_composite
(
std
::
vector
<
disposable
>
entries
);
...
...
libcaf_core/caf/scheduled_actor.hpp
View file @
a1fd7896
...
...
@@ -397,10 +397,10 @@ public:
// -- timeout management -----------------------------------------------------
/// Requests a new timeout for the current behavior
and returns its ID
.
/// Requests a new timeout for the current behavior.
void
set_receive_timeout
();
/// Requests a new timeout
and returns its ID
.
/// Requests a new timeout.
void
set_stream_timeout
(
actor_clock
::
time_point
x
);
// -- message processing -----------------------------------------------------
...
...
@@ -571,7 +571,7 @@ public:
/// Runs `what` asynchronously at some point after `when`.
/// @param when The local time until the actor waits before invoking the
/// action. Due to scheduling delays, there will always be some
/// additional wait time. Passing the current time or a past time
s
/// additional wait time. Passing the current time or a past time
/// immediately schedules the action for execution.
/// @param what The action to invoke after waiting on the timeout.
/// @returns A @ref disposable that allows the actor to cancel the action.
...
...
libcaf_core/src/detail/thread_safe_actor_clock.cpp
View file @
a1fd7896
...
...
@@ -19,7 +19,8 @@ thread_safe_actor_clock::thread_safe_actor_clock() {
disposable
thread_safe_actor_clock
::
schedule_periodically
(
time_point
first_run
,
action
f
,
duration_type
period
)
{
queue_
.
emplace_back
(
new
schedule_entry
{
first_run
,
f
,
period
});
auto
ptr
=
schedule_entry_ptr
{
new
schedule_entry
{
first_run
,
f
,
period
}};
queue_
.
emplace_back
(
std
::
move
(
ptr
));
return
std
::
move
(
f
).
as_disposable
();
}
...
...
libcaf_core/test/actor_clock.cpp
View file @
a1fd7896
...
...
@@ -66,20 +66,20 @@ struct fixture : test_coordinator_fixture<> {
CAF_TEST_FIXTURE_SCOPE
(
timer_tests
,
fixture
)
CAF_TEST
(
run_delayed
without
dispose
)
{
// Have AUT call
t.set_receive_timeout
().
// Have AUT call
self->run_delayed
().
self
->
send
(
aut
,
ok_atom_v
);
expect
((
ok_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
.
size
(),
1u
);
// Advance time to
send timeout message
.
// Advance time to
trigger timeout
.
t
.
advance_time
(
10s
);
CAF_CHECK_EQUAL
(
t
.
schedule
.
size
(),
0u
);
// Have AUT receive the
timeout
.
// Have AUT receive the
action
.
expect
((
action
),
to
(
aut
));
CAF_CHECK
(
state
().
run_delayed_called
);
}
CAF_TEST
(
run_delayed
with
dispose
before
expire
)
{
// Have AUT call
t.set_receive_timeout
().
// Have AUT call
self->run_delayed
().
self
->
send
(
aut
,
ok_atom_v
);
expect
((
ok_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
state
().
pending
.
dispose
();
...
...
@@ -93,7 +93,7 @@ CAF_TEST(run_delayed with dispose before expire) {
}
CAF_TEST
(
run_delayed
with
dispose
after
expire
)
{
// Have AUT call
t.set_receive_timeout
().
// Have AUT call
self->run_delayed
().
self
->
send
(
aut
,
ok_atom_v
);
expect
((
ok_atom
),
from
(
self
).
to
(
aut
).
with
(
_
));
CAF_CHECK_EQUAL
(
t
.
schedule
.
size
(),
1u
);
...
...
libcaf_core/test/detached_actors.cpp
View file @
a1fd7896
...
...
@@ -99,19 +99,3 @@ SCENARIO("an actor system shuts down after the last actor terminates") {
}
}
}
// CAF_TEST(shutdown_delayed_send_loop) {
// CAF_MESSAGE("does sys shut down after spawning a detached actor that used "
// "a delayed send loop and was interrupted via exit message?");
// auto f = [](event_based_actor* self) -> behavior {
// self->delayed_send(self, 1ns, ok_atom_v);
// return {
// [=](ok_atom) {
// self->delayed_send(self, 1ns, ok_atom_v);
// },
// };
// };
// auto a = sys.spawn<detached>(f);
// auto g = detail::make_scope_guard(
// [&] { self->send_exit(a, exit_reason::user_shutdown); });
// }
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