Commit 892e6ee7 authored by Dominik Charousset's avatar Dominik Charousset

Allow users to disable detaching of MM actors

parent a5c6c2b7
......@@ -45,4 +45,5 @@ app-identifier=""
max-consecutive-reads=50
; heartbeat message interval in ms (0 disables heartbeating)
heartbeat-interval=0
; configures whether the MM detaches its internal utility actors
middleman-detach-utility-actors=true
......@@ -272,6 +272,7 @@ public:
bool middleman_enable_automatic_connections;
size_t middleman_max_consecutive_reads;
size_t middleman_heartbeat_interval;
bool middleman_detach_utility_actors;
// -- config parameters of the OpenCL module ---------------------------------
......
......@@ -168,7 +168,9 @@ actor_system_config::actor_system_config()
.add(middleman_max_consecutive_reads, "max-consecutive-reads",
"sets the maximum number of consecutive I/O reads per broker")
.add(middleman_heartbeat_interval, "heartbeat-interval",
"sets the interval (ms) of heartbeat, 0 (default) means disabling it");
"sets the interval (ms) of heartbeat, 0 (default) means disabling it")
.add(middleman_detach_utility_actors, "detach-utility-actors",
"enables or disables detaching of utility actors");
opt_group(options_, "opencl")
.add(opencl_device_ids, "device-ids",
"restricts which OpenCL devices are accessed by CAF");
......
......@@ -369,6 +369,16 @@ void basp_broker_state::learned_new_node_directly(const node_id& nid,
learned_new_node(nid);
}
namespace {
struct connection_helper_state {
static const char* name;
};
const char* connection_helper_state::name = "connection_helper";
} // namespace <anonymous>
void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
CAF_ASSERT(this_context != nullptr);
CAF_LOG_TRACE(CAF_ARG(nid));
......@@ -379,7 +389,8 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
// indirect connection to the routing table; hence, spawning
// our helper here exactly once and there is no need to track
// in-flight connection requests
auto connection_helper = [=](event_based_actor* helper, actor s) -> behavior {
auto connection_helper = [=](stateful_actor<connection_helper_state>* helper,
actor s) -> behavior {
CAF_LOG_TRACE(CAF_ARG(s));
helper->monitor(s);
helper->set_down_handler([=](down_msg& dm) {
......@@ -432,7 +443,9 @@ void basp_broker_state::learned_new_node_indirectly(const node_id& nid) {
return;
}
using namespace detail;
auto tmp = system().spawn<detached + hidden>(connection_helper, self);
auto tmp = system().config().middleman_detach_utility_actors
? system().spawn<detached + hidden>(connection_helper, self)
: system().spawn<hidden>(connection_helper, self);
system().registry().put(tmp.id(), actor_cast<strong_actor_ptr>(tmp));
auto writer = make_callback([](serializer& sink) -> error {
auto name_atm = atom("ConfigServ");
......
......@@ -29,6 +29,7 @@
#include "caf/logger.hpp"
#include "caf/node_id.hpp"
#include "caf/actor_proxy.hpp"
#include "caf/actor_system_config.hpp"
#include "caf/typed_event_based_actor.hpp"
#include "caf/io/basp_broker.hpp"
......@@ -223,7 +224,9 @@ private:
} // namespace <anonymous>
middleman_actor make_middleman_actor(actor_system& sys, actor db) {
return sys.spawn<middleman_actor_impl, detached + hidden>(std::move(db));
return sys.config().middleman_detach_utility_actors
? sys.spawn<middleman_actor_impl, detached + hidden>(std::move(db))
: sys.spawn<middleman_actor_impl, hidden>(std::move(db));
}
} // namespace io
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment