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
593216a0
Commit
593216a0
authored
Aug 17, 2018
by
Dominik Charousset
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add runtime settings map to system plus cleanup
parent
e95b0674
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
73 additions
and
25 deletions
+73
-25
libcaf_core/caf/actor_system.hpp
libcaf_core/caf/actor_system.hpp
+73
-25
No files found.
libcaf_core/caf/actor_system.hpp
View file @
593216a0
...
@@ -27,26 +27,26 @@
...
@@ -27,26 +27,26 @@
#include <functional>
#include <functional>
#include <condition_variable>
#include <condition_variable>
#include "caf/fwd.hpp"
#include "caf/abstract_actor.hpp"
#include "caf/logger.hpp"
#include "caf/actor_cast.hpp"
#include "caf/actor_cast.hpp"
#include "caf/make_actor.hpp"
#include "caf/actor_clock.hpp"
#include "caf/actor_clock.hpp"
#include "caf/infer_handle.hpp"
#include "caf/actor_config.hpp"
#include "caf/actor_config.hpp"
#include "caf/spawn_options.hpp"
#include "caf/group_manager.hpp"
#include "caf/is_typed_actor.hpp"
#include "caf/abstract_actor.hpp"
#include "caf/actor_registry.hpp"
#include "caf/actor_registry.hpp"
#include "caf/string_algorithms.hpp"
#include "caf/scoped_execution_unit.hpp"
#include "caf/uniform_type_info_map.hpp"
#include "caf/composable_behavior_based_actor.hpp"
#include "caf/composable_behavior_based_actor.hpp"
#include "caf/prohibit_top_level_spawn_marker.hpp"
#include "caf/detail/init_fun_factory.hpp"
#include "caf/detail/init_fun_factory.hpp"
#include "caf/detail/spawn_fwd.hpp"
#include "caf/detail/spawn_fwd.hpp"
#include "caf/fwd.hpp"
#include "caf/group_manager.hpp"
#include "caf/infer_handle.hpp"
#include "caf/is_typed_actor.hpp"
#include "caf/logger.hpp"
#include "caf/make_actor.hpp"
#include "caf/prohibit_top_level_spawn_marker.hpp"
#include "caf/runtime_settings_map.hpp"
#include "caf/scoped_execution_unit.hpp"
#include "caf/spawn_options.hpp"
#include "caf/string_algorithms.hpp"
#include "caf/uniform_type_info_map.hpp"
namespace
caf
{
namespace
caf
{
...
@@ -137,13 +137,13 @@ public:
...
@@ -137,13 +137,13 @@ public:
}
}
/// Returns the internal actor for dynamic spawn operations.
/// Returns the internal actor for dynamic spawn operations.
inline
const
strong_actor_ptr
&
spawn_serv
()
const
{
const
strong_actor_ptr
&
spawn_serv
()
const
{
return
internal_actors_
[
internal_actor_id
(
atom
(
"SpawnServ"
))];
return
internal_actors_
[
internal_actor_id
(
atom
(
"SpawnServ"
))];
}
}
/// Returns the internal actor for storing the runtime configuration
/// Returns the internal actor for storing the runtime configuration
/// for this actor system.
/// for this actor system.
inline
const
strong_actor_ptr
&
config_serv
()
const
{
const
strong_actor_ptr
&
config_serv
()
const
{
return
internal_actors_
[
internal_actor_id
(
atom
(
"ConfigServ"
))];
return
internal_actors_
[
internal_actor_id
(
atom
(
"ConfigServ"
))];
}
}
...
@@ -226,7 +226,7 @@ public:
...
@@ -226,7 +226,7 @@ public:
/// Returns whether actor handles described by `xs`
/// Returns whether actor handles described by `xs`
/// can be assigned to actor handles described by `ys`.
/// can be assigned to actor handles described by `ys`.
/// @experimental
/// @experimental
inline
bool
assignable
(
const
mpi
&
xs
,
const
mpi
&
ys
)
const
{
bool
assignable
(
const
mpi
&
xs
,
const
mpi
&
ys
)
const
{
if
(
ys
.
empty
())
if
(
ys
.
empty
())
return
xs
.
empty
();
return
xs
.
empty
();
if
(
xs
.
size
()
==
ys
.
size
())
if
(
xs
.
size
()
==
ys
.
size
())
...
@@ -464,24 +464,34 @@ public:
...
@@ -464,24 +464,34 @@ public:
/// Returns whether this actor system calls `await_all_actors_done`
/// Returns whether this actor system calls `await_all_actors_done`
/// in its destructor before shutting down.
/// in its destructor before shutting down.
inline
bool
await_actors_before_shutdown
()
const
{
bool
await_actors_before_shutdown
()
const
{
return
await_actors_before_shutdown_
;
return
await_actors_before_shutdown_
;
}
}
/// Configures whether this actor system calls `await_all_actors_done`
/// Configures whether this actor system calls `await_all_actors_done`
/// in its destructor before shutting down.
/// in its destructor before shutting down.
inline
void
await_actors_before_shutdown
(
bool
x
)
{
void
await_actors_before_shutdown
(
bool
x
)
{
await_actors_before_shutdown_
=
x
;
await_actors_before_shutdown_
=
x
;
}
}
/// Returns the configuration of this actor system.
/// Returns the configuration of this actor system.
inline
const
actor_system_config
&
config
()
const
{
const
actor_system_config
&
config
()
const
{
return
cfg_
;
return
cfg_
;
}
}
/// Returns the system-wide clock.
/// Returns the system-wide clock.
actor_clock
&
clock
()
noexcept
;
actor_clock
&
clock
()
noexcept
;
/// Returns application-specific, system-wide runtime settings.
runtime_settings_map
&
runtime_settings
()
{
return
settings_
;
}
/// Returns application-specific, system-wide runtime settings.
const
runtime_settings_map
&
runtime_settings
()
const
{
return
settings_
;
}
/// @cond PRIVATE
/// @cond PRIVATE
/// Increases running-detached-threads-count by one.
/// Increases running-detached-threads-count by one.
...
@@ -538,33 +548,71 @@ private:
...
@@ -538,33 +548,71 @@ private:
optional
<
const
mpi
&>
expected_ifs
);
optional
<
const
mpi
&>
expected_ifs
);
/// Sets the internal actor for dynamic spawn operations.
/// Sets the internal actor for dynamic spawn operations.
inline
void
spawn_serv
(
strong_actor_ptr
x
)
{
void
spawn_serv
(
strong_actor_ptr
x
)
{
internal_actors_
[
internal_actor_id
(
atom
(
"SpawnServ"
))]
=
std
::
move
(
x
);
internal_actors_
[
internal_actor_id
(
atom
(
"SpawnServ"
))]
=
std
::
move
(
x
);
}
}
/// Sets the internal actor for storing the runtime configuration.
/// Sets the internal actor for storing the runtime configuration.
inline
void
config_serv
(
strong_actor_ptr
x
)
{
void
config_serv
(
strong_actor_ptr
x
)
{
internal_actors_
[
internal_actor_id
(
atom
(
"ConfigServ"
))]
=
std
::
move
(
x
);
internal_actors_
[
internal_actor_id
(
atom
(
"ConfigServ"
))]
=
std
::
move
(
x
);
}
}
// -- member variables -------------------------------------------------------
/// Used to generate ascending actor IDs.
std
::
atomic
<
size_t
>
ids_
;
std
::
atomic
<
size_t
>
ids_
;
/// Stores runtime type information for builtin and user-defined types.
uniform_type_info_map
types_
;
uniform_type_info_map
types_
;
/// Identifies this actor system in a distributed setting.
node_id
node_
;
node_id
node_
;
/// Manages log output.
intrusive_ptr
<
caf
::
logger
>
logger_
;
intrusive_ptr
<
caf
::
logger
>
logger_
;
/// Maps well-known actor names to actor handles.
actor_registry
registry_
;
actor_registry
registry_
;
/// Maps well-known group names to group handles.
group_manager
groups_
;
group_manager
groups_
;
/// Stores optional actor system components.
module_array
modules_
;
module_array
modules_
;
/// Provides pseudo scheduling context to actors.
scoped_execution_unit
dummy_execution_unit_
;
scoped_execution_unit
dummy_execution_unit_
;
/// Stores whether the system should wait for running actors on shutdown.
bool
await_actors_before_shutdown_
;
bool
await_actors_before_shutdown_
;
// Stores SpawnServ, ConfigServ, and StreamServ
/// Stores SpawnServ, ConfigServ, and StreamServ.
std
::
array
<
strong_actor_ptr
,
num_internal_actors
>
internal_actors_
;
std
::
array
<
strong_actor_ptr
,
num_internal_actors
>
internal_actors_
;
/// Counts the number of detached actors.
std
::
atomic
<
size_t
>
detached
;
std
::
atomic
<
size_t
>
detached
;
/// Guards `detached`.
mutable
std
::
mutex
detached_mtx
;
mutable
std
::
mutex
detached_mtx
;
/// Allows waiting on specific values for `detached`.
mutable
std
::
condition_variable
detached_cv
;
mutable
std
::
condition_variable
detached_cv
;
/// The system-wide, user-provided configuration.
actor_system_config
&
cfg_
;
actor_system_config
&
cfg_
;
std
::
mutex
logger_dtor_mtx_
;
std
::
condition_variable
logger_dtor_cv_
;
/// Stores whether the logger has run its destructor and stopped any thread,
volatile
bool
logger_dtor_done_
;
/// file handle, etc.
std
::
atomic
<
bool
>
logger_dtor_done_
;
/// Guards `logger_dtor_done_`.
mutable
std
::
mutex
logger_dtor_mtx_
;
/// Allows waiting on specific values for `logger_dtor_done_`.
mutable
std
::
condition_variable
logger_dtor_cv_
;
/// Stores custom, system-wide key-value pairs.
runtime_settings_map
settings_
;
};
};
}
// namespace caf
}
// namespace caf
...
...
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