Commit 639ac2ed authored by Dominik Charousset's avatar Dominik Charousset

Merge branch 'topic/neverlord/cleanup'

parents 6129cc74 01b82717
......@@ -16,7 +16,6 @@
#include "caf/abstract_channel.hpp"
#include "caf/attachable.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/functor_attachable.hpp"
#include "caf/detail/type_traits.hpp"
#include "caf/execution_unit.hpp"
......
......@@ -8,7 +8,6 @@
#include <memory>
#include "caf/detail/core_export.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/extend.hpp"
#include "caf/fwd.hpp"
......
......@@ -114,7 +114,7 @@ public:
template <size_t... Is>
bool invoke_impl(detail::invoke_result_visitor& f, message& msg,
std::index_sequence<Is...>) {
auto dispatch = [&](auto& fun) {
[[maybe_unused]] auto dispatch = [&](auto& fun) {
using fun_type = std::decay_t<decltype(fun)>;
using trait = get_callable_trait_t<fun_type>;
auto arg_types = to_type_id_list<typename trait::decayed_arg_types>();
......
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include <type_traits>
#include "caf/memory_managed.hpp"
namespace caf::detail {
class disposer {
public:
void operator()(memory_managed* ptr) const noexcept {
ptr->request_deletion(false);
}
template <class T>
typename std::enable_if<!std::is_base_of<memory_managed, T>::value>::type
operator()(T* ptr) const noexcept {
delete ptr;
}
};
} // namespace caf::detail
// This file is part of CAF, the C++ Actor Framework. See the file LICENSE in
// the main distribution directory for license terms and copyright or visit
// https://github.com/actor-framework/actor-framework/blob/master/LICENSE.
#pragma once
#include "caf/intrusive_ptr.hpp"
#include "caf/ref_counted.hpp"
namespace caf::detail {
template <class Base>
class embedded final : public Base {
public:
template <class... Ts>
embedded(intrusive_ptr<ref_counted> storage, Ts&&... xs)
: Base(std::forward<Ts>(xs)...), storage_(std::move(storage)) {
// nop
}
~embedded() {
// nop
}
void request_deletion(bool) noexcept override {
intrusive_ptr<ref_counted> guard;
guard.swap(storage_);
// this code assumes that embedded is part of pair_storage<>,
// i.e., this object lives inside a union!
this->~embedded();
}
protected:
intrusive_ptr<ref_counted> storage_;
};
} // namespace caf::detail
......@@ -35,7 +35,7 @@ void profiled_send(Self* self, SelfHandle&& src, const Handle& dst,
template <class Self, class SelfHandle, class Handle, class... Ts>
void profiled_send(Self* self, SelfHandle&& src, const Handle& dst,
actor_clock& clock, actor_clock::time_point timeout,
message_id msg_id, Ts&&... xs) {
[[maybe_unused]] message_id msg_id, Ts&&... xs) {
if (dst) {
if constexpr (std::is_same<Handle, group>::value) {
clock.schedule_message(timeout, dst, std::forward<SelfHandle>(src),
......
......@@ -15,7 +15,6 @@
#include "caf/detail/token_based_credit_controller.hpp"
#include "caf/downstream_msg.hpp"
#include "caf/logger.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/settings.hpp"
#include "caf/stream_aborter.hpp"
#include "caf/stream_priority.hpp"
......@@ -180,9 +179,12 @@ private:
/// @relates inbound_path
template <class Inspector>
typename Inspector::return_type inspect(Inspector& f, inbound_path& x) {
return f(meta::type_name("inbound_path"), x.hdl, x.slots, x.prio,
x.last_acked_batch_id, x.last_batch_id, x.assigned_credit);
bool inspect(Inspector& f, inbound_path& x) {
return f.object(x).fields(
f.field("hdl", x.hdl), f.field("slots", x.slots), f.field("prio", x.prio),
f.field("last_acked_batch_id", x.last_acked_batch_id),
f.field("last_batch_id", x.last_batch_id),
f.field("assigned_credit", x.assigned_credit));
}
} // namespace caf
......@@ -61,8 +61,7 @@ template <class T, class Inspector, class Obj>
class has_static_apply {
private:
template <class U>
static auto sfinae(Inspector* f, Obj* x)
-> decltype(U::apply(*f, *x), std::true_type());
static auto sfinae(Inspector* f, Obj* x) -> decltype(U::apply(*f, *x));
template <class U>
static auto sfinae(...) -> std::false_type;
......@@ -70,7 +69,8 @@ private:
using sfinae_type = decltype(sfinae<T>(nullptr, nullptr));
public:
static constexpr bool value = sfinae_type::value;
static constexpr bool value
= !std::is_same<sfinae_type, std::false_type>::value;
};
template <class T, class Inspector, class Obj>
......
......@@ -7,7 +7,6 @@
#include <type_traits>
#include "caf/fwd.hpp"
#include "caf/meta/type_name.hpp"
namespace caf::intrusive {
......
......@@ -10,7 +10,6 @@
#include "caf/detail/comparable.hpp"
#include "caf/detail/core_export.hpp"
#include "caf/ipv4_address.hpp"
#include "caf/meta/type_name.hpp"
namespace caf {
......
......@@ -11,7 +11,6 @@
#include "caf/detail/core_export.hpp"
#include "caf/fwd.hpp"
#include "caf/ipv6_address.hpp"
#include "caf/meta/type_name.hpp"
namespace caf {
......
......@@ -13,8 +13,6 @@
#include "caf/intrusive/singly_linked.hpp"
#include "caf/message.hpp"
#include "caf/message_id.hpp"
#include "caf/meta/omittable_if_empty.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/tracing_data.hpp"
namespace caf {
......
......@@ -8,18 +8,10 @@
namespace caf {
/// This base enables derived classes to enforce a different
/// allocation strategy than new/delete by providing a virtual
/// protected `request_deletion()` function and non-public destructor.
class [[deprecated]] memory_managed;
class CAF_CORE_EXPORT memory_managed {
public:
/// Default implementations calls `delete this, but can
/// be overridden in case deletion depends on some condition or
/// the class doesn't use default new/delete.
/// @param decremented_rc Indicates whether the caller did reduce the
/// reference of this object before calling this member
/// function. This information is important when
/// implementing a type with support for weak pointers.
virtual void request_deletion(bool decremented_rc) const noexcept;
protected:
......
......@@ -14,7 +14,6 @@
#include "caf/error.hpp"
#include "caf/inspector_access.hpp"
#include "caf/message_priority.hpp"
#include "caf/meta/type_name.hpp"
namespace caf {
......
......@@ -8,7 +8,6 @@
namespace caf::meta {
/// Type tag for all meta annotations in CAF.
struct annotation {
constexpr annotation() {
// nop
......@@ -30,6 +29,6 @@ template <class T>
struct is_annotation<T&&> : is_annotation<T> {};
template <class T>
constexpr bool is_annotation_v = is_annotation<T>::value;
[[deprecated]] constexpr bool is_annotation_v = is_annotation<T>::value;
} // namespace caf::meta
......@@ -14,8 +14,7 @@ struct hex_formatted_t : annotation {
}
};
/// Advises the inspector to format the following data field in hex format.
constexpr hex_formatted_t hex_formatted() {
[[deprecated]] constexpr hex_formatted_t hex_formatted() {
return {};
}
......
......@@ -33,10 +33,8 @@ struct is_load_callback<load_callback_t<F>> : std::true_type {};
template <class F>
constexpr bool is_load_callback_v = is_load_callback<F>::value;
/// Returns an annotation that allows inspectors to call
/// user-defined code after performing load operations.
template <class F>
load_callback_t<F> load_callback(F fun) {
[[deprecated]] load_callback_t<F> load_callback(F fun) {
return {std::move(fun)};
}
......
......@@ -14,9 +14,7 @@ struct omittable_t : annotation {
}
};
/// Allows an inspector to omit the following data field
/// unconditionally when producing human-friendly output.
constexpr omittable_t omittable() {
[[deprecated]] constexpr omittable_t omittable() {
return {};
}
......
......@@ -14,8 +14,7 @@ struct omittable_if_empty_t : annotation {
}
};
/// Allows an inspector to omit the following data field if it is empty.
constexpr omittable_if_empty_t omittable_if_empty() {
[[deprecated]] constexpr omittable_if_empty_t omittable_if_empty() {
return {};
}
......
......@@ -14,8 +14,7 @@ struct omittable_if_none_t : annotation {
}
};
/// Allows an inspector to omit the following data field if it is empty.
constexpr omittable_if_none_t omittable_if_none() {
[[deprecated]] constexpr omittable_if_none_t omittable_if_none() {
return {};
}
......
......@@ -32,10 +32,8 @@ struct is_save_callback<save_callback_t<F>> : std::true_type {};
template <class F>
constexpr bool is_save_callback_v = is_save_callback<F>::value;
/// Returns an annotation that allows inspectors to call
/// user-defined code after performing save operations.
template <class F>
save_callback_t<F> save_callback(F fun) {
[[deprecated]] save_callback_t<F> save_callback(F fun) {
return {std::move(fun)};
}
......
......@@ -16,8 +16,8 @@ struct type_name_t : annotation {
const char* value;
};
/// Returns a type name annotation.
type_name_t constexpr type_name(const char* cstr) {
[[deprecated]] type_name_t constexpr type_name(const char* cstr) {
return {cstr};
}
} // namespace caf::meta
......@@ -15,7 +15,6 @@
#include "caf/downstream_msg.hpp"
#include "caf/fwd.hpp"
#include "caf/logger.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/stream_aborter.hpp"
#include "caf/stream_slot.hpp"
#include "caf/system_messages.hpp"
......
......@@ -8,7 +8,6 @@
#include <cstddef>
#include "caf/detail/core_export.hpp"
#include "caf/memory_managed.hpp"
namespace caf {
......@@ -16,9 +15,9 @@ namespace caf {
/// Serves the requirements of {@link intrusive_ptr}.
/// @note *All* instances of `ref_counted` start with a reference count of 1.
/// @relates intrusive_ptr
class CAF_CORE_EXPORT ref_counted : public memory_managed {
class CAF_CORE_EXPORT ref_counted {
public:
~ref_counted() override;
virtual ~ref_counted();
ref_counted();
ref_counted(const ref_counted&);
......
......@@ -15,8 +15,6 @@
#include "caf/detail/core_export.hpp"
#include "caf/detail/squashed_int.hpp"
#include "caf/fwd.hpp"
#include "caf/meta/annotation.hpp"
#include "caf/meta/save_callback.hpp"
#include "caf/save_inspector_base.hpp"
#include "caf/sec.hpp"
#include "caf/span.hpp"
......
......@@ -5,7 +5,6 @@
#pragma once
#include "caf/fwd.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/type_id.hpp"
namespace caf {
......
......@@ -12,7 +12,6 @@
#include "caf/deep_to_string.hpp"
#include "caf/fwd.hpp"
#include "caf/group.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/stream_slot.hpp"
namespace caf {
......
......@@ -14,7 +14,6 @@
#include "caf/detail/pp.hpp"
#include "caf/detail/squashed_int.hpp"
#include "caf/fwd.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/string_view.hpp"
#include "caf/timespan.hpp"
#include "caf/timestamp.hpp"
......
......@@ -17,7 +17,6 @@
#include "caf/actor_system.hpp"
#include "caf/config.hpp"
#include "caf/default_attachable.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/shared_spinlock.hpp"
#include "caf/execution_unit.hpp"
#include "caf/logger.hpp"
......
......@@ -6,7 +6,6 @@
#include "caf/abstract_actor.hpp"
#include "caf/actor_system.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/mailbox_element.hpp"
#include "caf/message.hpp"
#include "caf/proxy_registry.hpp"
......
......@@ -66,7 +66,7 @@ constexpr size_t max_value = static_cast<size_t>(std::numeric_limits<T>::max());
bool binary_serializer::begin_field(string_view, span<const type_id_t> types,
size_t index) {
CAF_ASSERT(index >= 0 && index < types.size());
CAF_ASSERT(index < types.size());
if (types.size() < max_value<int8_t>) {
return value(static_cast<int8_t>(index));
} else if (types.size() < max_value<int16_t>) {
......@@ -91,7 +91,7 @@ T compress_index(bool is_present, size_t value) {
bool binary_serializer::begin_field(string_view, bool is_present,
span<const type_id_t> types, size_t index) {
CAF_ASSERT(!is_present || (index >= 0 && index < types.size()));
CAF_ASSERT(!is_present || index < types.size());
if (types.size() < max_value<int8_t>) {
return value(compress_index<int8_t>(is_present, index));
} else if (types.size() < max_value<int16_t>) {
......
......@@ -6,8 +6,6 @@
#include "caf/actor_system.hpp"
#include "caf/default_attachable.hpp"
#include "caf/detail/disposer.hpp"
#include "caf/detail/sync_request_bouncer.hpp"
namespace caf::decorator {
......
......@@ -24,13 +24,8 @@ ref_counted& ref_counted::operator=(const ref_counted&) {
}
void ref_counted::deref() const noexcept {
if (unique()) {
request_deletion(false);
return;
}
if (rc_.fetch_sub(1, std::memory_order_acq_rel) == 1) {
request_deletion(true);
}
if (unique() || rc_.fetch_sub(1, std::memory_order_acq_rel) == 1)
delete this;
}
} // namespace caf
......@@ -17,7 +17,7 @@ using namespace std::string_literals;
namespace {
using typed_adder_actor
= typed_actor<reacts_to<add_atom, int>, replies_to<get_atom>::with<int>>;
= typed_actor<result<void>(add_atom, int), result<int>(get_atom)>;
struct counter {
int value = 0;
......@@ -49,9 +49,9 @@ typed_adder(typed_adder_actor::stateful_pointer<counter> self) {
};
}
class typed_adder_class : public typed_adder_actor::stateful_base<counter> {
class typed_adder_class : public typed_adder_actor::stateful_impl<counter> {
public:
using super = typed_adder_actor::stateful_base<counter>;
using super = typed_adder_actor::stateful_impl<counter>;
typed_adder_class(actor_config& cfg) : super(cfg) {
// nop
......@@ -185,7 +185,7 @@ CAF_TEST(typed actors can use typed_actor_pointer as self pointer) {
[=](get_atom) { return value; });
}
};
using actor_type = typed_adder_actor::stateful_base<state_type>;
using actor_type = typed_adder_actor::stateful_impl<state_type>;
auto testee = sys.spawn<actor_type>(10);
auto& state = deref<actor_type>(testee).state;
CAF_CHECK(state.self == &deref<actor_type>(testee));
......
......@@ -7,11 +7,8 @@
#include <functional>
#include "caf/error.hpp"
#include "caf/io/handle.hpp"
#include "caf/meta/type_name.hpp"
namespace caf::io {
struct invalid_accept_handle_t {
......
......@@ -10,8 +10,6 @@
#include "caf/detail/io_export.hpp"
#include "caf/error.hpp"
#include "caf/io/basp/message_type.hpp"
#include "caf/meta/omittable.hpp"
#include "caf/meta/type_name.hpp"
#include "caf/node_id.hpp"
namespace caf::io::basp {
......
......@@ -7,11 +7,8 @@
#include <functional>
#include "caf/error.hpp"
#include "caf/io/handle.hpp"
#include "caf/meta/type_name.hpp"
namespace caf::io {
struct invalid_connection_handle_t {
......
......@@ -7,11 +7,8 @@
#include <functional>
#include "caf/error.hpp"
#include "caf/io/handle.hpp"
#include "caf/meta/type_name.hpp"
namespace caf::io {
struct invalid_datagram_handle_t {
......
......@@ -8,7 +8,6 @@
#include <string>
#include "caf/detail/io_export.hpp"
#include "caf/meta/type_name.hpp"
namespace caf::io::network {
......
......@@ -15,8 +15,6 @@
#include "caf/io/datagram_handle.hpp"
#include "caf/io/handle.hpp"
#include "caf/io/network/receive_buffer.hpp"
#include "caf/meta/hex_formatted.hpp"
#include "caf/meta/type_name.hpp"
namespace caf::io {
......
......@@ -12,7 +12,6 @@
#include "caf/config.hpp"
#include "caf/detail/gcd.hpp"
#include "caf/init_global_meta_objects.hpp"
#include "caf/meta/annotation.hpp"
#include "caf/test/unit_test.hpp"
CAF_PUSH_WARNINGS
......
......@@ -280,9 +280,9 @@ types shown below to grant access to derived types.
+------------------------+---------------------------------------------------------------+
| ``pointer`` | A pointer of type ``base*``. |
+------------------------+---------------------------------------------------------------+
| ``stateful_base<T>`` | See stateful-actor_. |
| ``stateful_impl<T>`` | See stateful-actor_. |
+------------------------+---------------------------------------------------------------+
| ``stateful_pointer<T>``| A pointer of type ``stateful_base<T>*``. |
| ``stateful_pointer<T>``| A pointer of type ``stateful_impl<T>*``. |
+------------------------+---------------------------------------------------------------+
| ``extend<Ts...>`` | Extend this typed actor with ``Ts...``. |
+------------------------+---------------------------------------------------------------+
......
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