Include review feedback

parent 13274198
......@@ -660,7 +660,7 @@ private:
expected<strong_actor_ptr>
dyn_spawn_impl(const std::string& name, message& args, execution_unit* ctx,
bool check_interface, std::optional<const mpi*> expected_ifs);
bool check_interface, const mpi* expected_ifs);
/// Sets the internal actor for dynamic spawn operations.
void spawn_serv(strong_actor_ptr x) {
......
......@@ -21,7 +21,7 @@ namespace caf {
class message_handler;
/// Describes the behavior of an actor, i.e., provides a message
/// handler and an std::optional timeout.
/// handler and an optional timeout.
class CAF_CORE_EXPORT behavior {
public:
friend class message_handler;
......
......@@ -38,7 +38,7 @@ void read_floating_point(State& ps, Consumer&& consumer,
enum sign_t { plus, minus };
sign_t sign;
ValueType result;
if (start_value == std::nullopt) {
if (!start_value) {
sign = plus;
result = 0;
} else if (*start_value < 0) {
......@@ -97,7 +97,7 @@ void read_floating_point(State& ps, Consumer&& consumer,
// Definition of our parser FSM.
start();
unstable_state(init) {
epsilon_if(start_value == std::nullopt, regular_init)
epsilon_if(!start_value, regular_init)
epsilon(after_dec, "eE.")
epsilon(after_dot, any_char)
}
......
......@@ -516,7 +516,7 @@ void actor_system::thread_terminates() {
expected<strong_actor_ptr>
actor_system::dyn_spawn_impl(const std::string& name, message& args,
execution_unit* ctx, bool check_interface,
std::optional<const mpi*> expected_ifs) {
const mpi* expected_ifs) {
CAF_LOG_TRACE(CAF_ARG(name) << CAF_ARG(args) << CAF_ARG(check_interface)
<< CAF_ARG(expected_ifs));
if (name.empty())
......@@ -529,7 +529,7 @@ actor_system::dyn_spawn_impl(const std::string& name, message& args,
auto res = i->second(cfg, args);
if (!res.first)
return sec::cannot_spawn_actor_from_arguments;
if (check_interface && !assignable(res.second, **expected_ifs))
if (check_interface && !assignable(res.second, *expected_ifs))
return sec::unexpected_actor_messaging_interface;
return std::move(res.first);
}
......
......@@ -283,7 +283,7 @@ public:
auto x = by_id(hdl);
if (!x)
return false;
(*x)->graceful_shutdown();
x->graceful_shutdown();
return true;
}
......@@ -386,11 +386,11 @@ protected:
/// Returns a `scribe` or `doorman` identified by `hdl`.
template <class Handle>
auto by_id(Handle hdl) -> std::optional<decltype(ptr_of(hdl))> {
auto by_id(Handle hdl) -> decltype(ptr_of(hdl)) {
auto& elements = get_map(hdl);
auto i = elements.find(hdl);
if (i == elements.end())
return std::nullopt;
return nullptr;
return std::addressof(*(i->second));
}
......
......@@ -73,10 +73,10 @@ private:
put_res put_udp(uint16_t port, strong_actor_ptr& whom, mpi_set& sigs,
const char* in = nullptr, bool reuse_addr = false);
std::optional<endpoint_data*> cached_tcp(const endpoint& ep);
std::optional<endpoint_data*> cached_udp(const endpoint& ep);
endpoint_data* cached_tcp(const endpoint& ep);
endpoint_data* cached_udp(const endpoint& ep);
std::optional<std::vector<response_promise>*> pending(const endpoint& ep);
std::vector<response_promise>* pending(const endpoint& ep);
actor broker_;
std::map<endpoint, endpoint_data> cached_tcp_;
......
......@@ -59,19 +59,19 @@ void abstract_broker::configure_read(connection_handle hdl,
receive_policy::config cfg) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(cfg));
if (auto x = by_id(hdl))
(*x)->configure_read(cfg);
x->configure_read(cfg);
}
void abstract_broker::ack_writes(connection_handle hdl, bool enable) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(enable));
if (auto x = by_id(hdl))
(*x)->ack_writes(enable);
x->ack_writes(enable);
}
byte_buffer& abstract_broker::wr_buf(connection_handle hdl) {
CAF_ASSERT(hdl != invalid_connection_handle);
if (auto x = by_id(hdl)) {
return (*x)->wr_buf();
return x->wr_buf();
} else {
CAF_LOG_ERROR("tried to access wr_buf() of an unknown connection_handle:"
<< CAF_ARG(hdl));
......@@ -92,18 +92,18 @@ void abstract_broker::write(connection_handle hdl, span<const byte> buf) {
void abstract_broker::flush(connection_handle hdl) {
if (auto x = by_id(hdl))
(*x)->flush();
x->flush();
}
void abstract_broker::ack_writes(datagram_handle hdl, bool enable) {
CAF_LOG_TRACE(CAF_ARG(hdl) << CAF_ARG(enable));
if (auto x = by_id(hdl))
(*x)->ack_writes(enable);
x->ack_writes(enable);
}
byte_buffer& abstract_broker::wr_buf(datagram_handle hdl) {
if (auto x = by_id(hdl)) {
return (*x)->wr_buf(hdl);
return x->wr_buf(hdl);
} else {
CAF_LOG_ERROR("tried to access wr_buf() of an unknown"
"datagram_handle");
......@@ -113,7 +113,7 @@ byte_buffer& abstract_broker::wr_buf(datagram_handle hdl) {
void abstract_broker::enqueue_datagram(datagram_handle hdl, byte_buffer buf) {
if (auto x = by_id(hdl))
(*x)->enqueue_datagram(hdl, std::move(buf));
x->enqueue_datagram(hdl, std::move(buf));
else
CAF_LOG_ERROR("tried to access datagram_buffer() of an unknown"
"datagram_handle");
......@@ -128,7 +128,7 @@ void abstract_broker::write(datagram_handle hdl, size_t bs, const void* buf) {
void abstract_broker::flush(datagram_handle hdl) {
if (auto x = by_id(hdl))
(*x)->flush();
x->flush();
}
std::vector<connection_handle> abstract_broker::connections() const {
......@@ -316,7 +316,7 @@ uint16_t abstract_broker::local_port(datagram_handle hdl) {
bool abstract_broker::remove_endpoint(datagram_handle hdl) {
if (auto x = by_id(hdl)) {
(*x)->remove_endpoint(hdl);
x->remove_endpoint(hdl);
return true;
} else {
return false;
......
......@@ -191,7 +191,7 @@ behavior basp_broker::make_behavior() {
return;
}
auto route = instance.tbl().lookup(proxy->node());
if (route == std::nullopt) {
if (!route) {
CAF_LOG_DEBUG("connection to origin already lost, kill proxy");
instance.proxies().erase(proxy->node(), proxy->id());
return;
......@@ -217,7 +217,7 @@ behavior basp_broker::make_behavior() {
}
// Check whether the node is still connected at the moment and send the
// observer a message immediately otherwise.
if (instance.tbl().lookup(node) == std::nullopt) {
if (!instance.tbl().lookup(node)) {
if (auto hdl = actor_cast<actor>(observer)) {
// TODO: we might want to consider keeping the exit reason for nodes,
// at least for some time. Otherwise, we'll have to send a
......@@ -472,7 +472,7 @@ void basp_broker::finalize_handshake(const node_id& nid, actor_id aid,
CAF_ASSERT(this_context != nullptr);
this_context->id = nid;
auto& cb = this_context->callback;
if (cb == std::nullopt)
if (!cb)
return;
strong_actor_ptr ptr;
// aid can be invalid when connecting to the default port of a node
......
......@@ -79,14 +79,14 @@ auto middleman_actor_impl::make_behavior() -> behavior_type {
auto x = cached_tcp(key);
if (x) {
CAF_LOG_DEBUG("found cached entry" << CAF_ARG(*x));
rp.deliver(get<0>(**x), get<1>(**x), get<2>(**x));
rp.deliver(get<0>(*x), get<1>(*x), get<2>(*x));
return get_delegated{};
}
// attach this promise to a pending request if possible
auto rps = pending(key);
if (rps) {
CAF_LOG_DEBUG("attach to pending request");
(*rps)->emplace_back(std::move(rp));
rps->emplace_back(std::move(rp));
return get_delegated{};
}
// connect to endpoint and initiate handhsake etc.
......@@ -216,28 +216,28 @@ middleman_actor_impl::put_udp(uint16_t port, strong_actor_ptr& whom,
return actual_port;
}
std::optional<middleman_actor_impl::endpoint_data*>
middleman_actor_impl::endpoint_data*
middleman_actor_impl::cached_tcp(const endpoint& ep) {
auto i = cached_tcp_.find(ep);
if (i != cached_tcp_.end())
return std::addressof(i->second);
return std::nullopt;
return nullptr;
}
std::optional<middleman_actor_impl::endpoint_data*>
middleman_actor_impl::endpoint_data*
middleman_actor_impl::cached_udp(const endpoint& ep) {
auto i = cached_udp_.find(ep);
if (i != cached_udp_.end())
return std::addressof(i->second);
return std::nullopt;
return nullptr;
}
std::optional<std::vector<response_promise>*>
std::vector<response_promise>*
middleman_actor_impl::pending(const endpoint& ep) {
auto i = pending_.find(ep);
if (i != pending_.end())
return std::addressof(i->second);
return std::nullopt;
return nullptr;
}
expected<scribe_ptr> middleman_actor_impl::connect(const std::string& host,
......
......@@ -229,7 +229,7 @@ std::optional<std::tuple<Ts...>> default_extract(caf_handle x) {
template <class T>
std::optional<std::tuple<T>> unboxing_extract(caf_handle x) {
auto tup = default_extract<typename T::outer_type>(x);
if (tup == std::nullopt || !is<T>(get<0>(*tup)))
if (!tup || !is<T>(get<0>(*tup)))
return std::nullopt;
return std::make_tuple(get<T>(get<0>(*tup)));
}
......@@ -266,7 +266,7 @@ std::optional<std::tuple<T, Ts...>> try_extract(caf_handle x) {
template <class T, class... Ts>
std::tuple<T, Ts...> extract(caf_handle x) {
auto result = try_extract<T, Ts...>(x);
if (result == std::nullopt) {
if (!result) {
auto ptr = x->peek_at_next_mailbox_element();
if (ptr == nullptr)
CAF_FAIL("Mailbox is empty");
......
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