Commit 8a47221b authored by Dominik Charousset's avatar Dominik Charousset Committed by Dominik Charousset

Fix up-/downstream message names in docs

parent 665c4ff7
No preview for this file type
......@@ -46,8 +46,8 @@
#include "caf/composable_behavior_based_actor.hpp"
#include "caf/prohibit_top_level_spawn_marker.hpp"
#include "caf/detail/spawn_fwd.hpp"
#include "caf/detail/init_fun_factory.hpp"
#include "caf/detail/spawn_fwd.hpp"
namespace caf {
......@@ -502,32 +502,17 @@ public:
/// @warning must be called by thread which is about to terminate
void thread_terminates();
/// @endcond
private:
template <class T>
void check_invariants() {
static_assert(!std::is_base_of<prohibit_top_level_spawn_marker, T>::value,
"This actor type cannot be spawned throught an actor system. "
"Probably you have tried to spawn a broker or opencl actor.");
}
expected<strong_actor_ptr> dyn_spawn_impl(const std::string& name,
message& args,
execution_unit* ctx,
bool check_interface,
optional<const mpi&> expected_ifs);
template <class C, spawn_options Os, class... Ts>
infer_handle_from_class_t<C>
spawn_impl(actor_config& cfg, Ts&&... xs) {
static_assert(is_unbound(Os),
"top-level spawns cannot have monitor or link flag");
// TODO: use `if constexpr` when switching to C++17
if (has_detach_flag(Os) || std::is_base_of<blocking_actor, C>::value)
cfg.flags |= abstract_actor::is_detached_flag;
if (has_hide_flag(Os))
cfg.flags |= abstract_actor::is_hidden_flag;
if (!cfg.host)
if (cfg.host == nullptr)
cfg.host = dummy_execution_unit();
CAF_SET_LOGGER_SYS(this);
auto res = make_actor<C>(next_actor_id(), node(), this,
......@@ -537,6 +522,22 @@ private:
return res;
}
/// @endcond
private:
template <class T>
void check_invariants() {
static_assert(!std::is_base_of<prohibit_top_level_spawn_marker, T>::value,
"This actor type cannot be spawned throught an actor system. "
"Probably you have tried to spawn a broker or opencl actor.");
}
expected<strong_actor_ptr> dyn_spawn_impl(const std::string& name,
message& args,
execution_unit* ctx,
bool check_interface,
optional<const mpi&> expected_ifs);
/// Sets the internal actor for dynamic spawn operations.
inline void spawn_serv(strong_actor_ptr x) {
internal_actors_[internal_actor_id(atom("SpawnServ"))] = std::move(x);
......
......@@ -25,6 +25,7 @@
#include "caf/fwd.hpp"
#include "caf/detail/apply_args.hpp"
#include "caf/detail/spawn_fwd.hpp"
#include "caf/detail/type_traits.hpp"
namespace caf {
......
......@@ -67,7 +67,7 @@ public:
}
error handle(inbound_path*, downstream_msg::batch& x) override {
CAF_LOG_TRACE(CAF_ARG(msg));
CAF_LOG_TRACE(CAF_ARG(x));
using vec_type = std::vector<input_type>;
if (x.xs.match_elements<vec_type>()) {
auto& xs = x.xs.get_as<vec_type>(0);
......
......@@ -64,7 +64,7 @@ public:
}
error handle(inbound_path*, downstream_msg::batch& x) override {
CAF_LOG_TRACE(CAF_ARG(msg));
CAF_LOG_TRACE(CAF_ARG(x));
using vec_type = std::vector<output_type>;
if (x.xs.match_elements<vec_type>()) {
auto& xs = x.xs.get_as<vec_type>(0);
......
......@@ -58,6 +58,11 @@ namespace caf {
/// living in an own thread or cooperatively scheduled.
class local_actor : public monitorable_actor {
public:
// -- member types -----------------------------------------------------------
/// Defines a monotonic clock suitable for measuring intervals.
using clock_type = std::chrono::steady_clock;
// -- constructors, destructors, and assignment operators --------------------
local_actor(actor_config& cfg);
......@@ -70,6 +75,17 @@ public:
virtual void launch(execution_unit* eu, bool lazy, bool hide) = 0;
// -- time -------------------------------------------------------------------
/// Returns the current time.
clock_type::time_point now() const noexcept;
/// Returns the difference between `t0` and `t1`, allowing the clock to
/// return any arbitrary value depending on the measurement that took place.
clock_type::duration difference(atom_value measurement,
clock_type::time_point t0,
clock_type::time_point t1);
// -- timeout management -----------------------------------------------------
/// Requests a new timeout for `mid`.
......
......@@ -33,8 +33,12 @@ std::string to_string(const actor_config& x) {
// Note: x.groups is an input range. Traversing it is emptying it, hence we
// cannot look inside the range here.
std::string result = "actor_config(";
bool first = false;
auto add = [&](int flag, const char* name) {
if ((x.flags & flag) != 0) {
if (first)
first = false;
else
result += ", ";
result += name;
}
......
......@@ -408,7 +408,6 @@ actor_clock& actor_system::clock() noexcept {
return scheduler().clock();
}
void actor_system::inc_detached_threads() {
++detached;
}
......
......@@ -30,7 +30,7 @@ namespace {
class impl : public blocking_actor {
public:
impl(actor_config& cfg) : blocking_actor(cfg) {
setf(is_detached_flag);
// nop
}
void act() override {
......@@ -40,6 +40,14 @@ public:
const char* name() const override {
return "scoped_actor";
}
void launch(execution_unit*, bool, bool hide) override {
CAF_LOG_TRACE(CAF_ARG(hide));
CAF_ASSERT(getf(is_blocking_flag));
if (!hide)
register_at_system();
initialize();
}
};
} // namespace <anonymous>
......@@ -47,12 +55,11 @@ public:
scoped_actor::scoped_actor(actor_system& sys, bool hide) : context_(&sys) {
CAF_SET_LOGGER_SYS(&sys);
actor_config cfg{&context_};
self_ = make_actor<impl, strong_actor_ptr>(sys.next_actor_id(), sys.node(),
&sys, cfg);
if (!hide)
ptr()->register_at_system();
if (hide)
cfg.flags |= abstract_actor::is_hidden_flag;
auto hdl = sys.spawn_impl<impl, no_spawn_options>(cfg);
self_ = actor_cast<strong_actor_ptr>(std::move(hdl));
prev_ = CAF_SET_AID(self_->id());
ptr()->initialize();
}
scoped_actor::~scoped_actor() {
......
......@@ -221,43 +221,7 @@ using mboxqueue = wdrr_fixed_multiplexed_queue<mboxpolicy, default_queue,
umsg_queue, dmsg_queue,
default_queue>;
// -- entity -------------------------------------------------------------------
class abstract_clock {
public:
// -- member types -----------------------------------------------------------
using time_point = std::chrono::steady_clock::time_point;
// -- constructors, destructors, and assignment operators --------------------
virtual ~abstract_clock() {
// nop
}
virtual time_point now() const noexcept = 0;
};
class fake_clock : public abstract_clock {
public:
fake_clock(time_point* global_time) : global_time_(global_time) {
// nop
}
time_point now() const noexcept override {
return *global_time_;
}
private:
time_point* global_time_;
};
class steady_clock : public abstract_clock {
public:
time_point now() const noexcept override {
return std::chrono::steady_clock::now();
}
};
// -- entity and mailbox visitor -----------------------------------------------
class entity : public extend<local_actor, entity>::with<mixin::sender> {
public:
......
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