Skip to content

Commit b27874f

Browse files
committed
Cleanup
1 parent ff0a890 commit b27874f

14 files changed

Lines changed: 107 additions & 102 deletions

libcaf_net/CMakeLists.txt

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,28 @@ file(GLOB_RECURSE CAF_NET_HEADERS "caf/*.hpp")
55
# -- add consistency checks for enum to_string implementations -----------------
66

77
caf_incubator_add_enum_consistency_check("caf/net/basp/ec.hpp"
8-
"src/basp/ec_strings.cpp")
8+
"src/basp/ec_strings.cpp")
99
caf_incubator_add_enum_consistency_check("caf/net/basp/message_type.hpp"
10-
"src/basp/message_type_strings.cpp")
10+
"src/basp/message_type_strings.cpp")
1111
caf_incubator_add_enum_consistency_check("caf/net/operation.hpp"
12-
"src/basp/operation_strings.cpp")
12+
"src/basp/operation_strings.cpp")
1313

1414
# -- utility function for setting default properties ---------------------------
1515

1616
function(caf_net_set_default_properties)
17-
foreach (target ${ARGN})
18-
caf_incubator_set_default_properties(${target})
19-
# Make sure we find our headers plus the the generated export header.
20-
target_include_directories(${target} PRIVATE
21-
"${CMAKE_CURRENT_SOURCE_DIR}"
22-
"${CMAKE_BINARY_DIR}")
23-
target_compile_definitions(${target} PRIVATE libcaf_net_EXPORTS)
24-
# Pull in public dependencies.
25-
target_link_libraries(${target} PUBLIC CAF::core)
26-
if (MSVC)
27-
target_link_libraries(${target} PUBLIC ws2_32 iphlpapi)
28-
endif ()
29-
endforeach ()
17+
foreach(target ${ARGN})
18+
caf_incubator_set_default_properties(${target})
19+
# Make sure we find our headers plus the the generated export header.
20+
target_include_directories(${target} PRIVATE
21+
"${CMAKE_CURRENT_SOURCE_DIR}"
22+
"${CMAKE_BINARY_DIR}")
23+
target_compile_definitions(${target} PRIVATE libcaf_net_EXPORTS)
24+
# Pull in public dependencies.
25+
target_link_libraries(${target} PUBLIC CAF::core)
26+
if(MSVC)
27+
target_link_libraries(${target} PUBLIC ws2_32 iphlpapi)
28+
endif()
29+
endforeach()
3030
endfunction()
3131

3232
# -- add library targets -------------------------------------------------------
@@ -66,27 +66,27 @@ add_library(libcaf_net_obj OBJECT ${CAF_NET_HEADERS}
6666
)
6767

6868
add_library(libcaf_net "${PROJECT_SOURCE_DIR}/cmake/dummy.cpp"
69-
$<TARGET_OBJECTS:libcaf_net_obj>)
69+
$<TARGET_OBJECTS:libcaf_net_obj>)
7070

7171
generate_export_header(libcaf_net
72-
EXPORT_MACRO_NAME CAF_NET_EXPORT
73-
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/caf/detail/net_export.hpp")
72+
EXPORT_MACRO_NAME CAF_NET_EXPORT
73+
EXPORT_FILE_NAME "${CMAKE_BINARY_DIR}/caf/detail/net_export.hpp")
7474

7575
set_property(TARGET libcaf_net_obj PROPERTY POSITION_INDEPENDENT_CODE ON)
7676

7777
caf_net_set_default_properties(libcaf_net_obj libcaf_net)
7878

7979
target_include_directories(libcaf_net INTERFACE
80-
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
81-
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
80+
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
81+
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}>)
8282

8383
add_library(CAF::net ALIAS libcaf_net)
8484

8585
set_target_properties(libcaf_net PROPERTIES
86-
EXPORT_NAME net
87-
SOVERSION ${CAF_VERSION}
88-
VERSION ${CAF_LIB_VERSION}
89-
OUTPUT_NAME caf_net)
86+
EXPORT_NAME net
87+
SOVERSION ${CAF_VERSION}
88+
VERSION ${CAF_LIB_VERSION}
89+
OUTPUT_NAME caf_net)
9090

9191
# -- install library and header files ------------------------------------------
9292

@@ -106,13 +106,13 @@ install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/caf"
106106

107107
# -- build unit tests ----------------------------------------------------------
108108

109-
if (NOT CAF_INC_ENABLE_TESTING)
110-
return()
111-
endif ()
109+
if(NOT CAF_INC_ENABLE_TESTING)
110+
return()
111+
endif()
112112

113113
add_executable(caf-net-test
114-
test/net-test.cpp
115-
$<TARGET_OBJECTS:libcaf_net_obj>)
114+
test/net-test.cpp
115+
$<TARGET_OBJECTS:libcaf_net_obj>)
116116

117117
caf_net_set_default_properties(caf-net-test)
118118

libcaf_net/caf/net/actor_proxy_impl.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020

2121
#include "caf/actor_proxy.hpp"
2222
#include "caf/net/consumer.hpp"
23-
#include "caf/net/socket_manager.hpp"
2423

2524
namespace caf::net {
2625

libcaf_net/caf/net/basp/application.hpp

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
#pragma once
2020

2121
#include <cstdint>
22-
#include <iterator>
2322
#include <memory>
2423
#include <type_traits>
2524
#include <unordered_map>
@@ -28,7 +27,6 @@
2827

2928
#include "caf/actor.hpp"
3029
#include "caf/actor_addr.hpp"
31-
#include "caf/actor_clock.hpp"
3230
#include "caf/actor_system.hpp"
3331
#include "caf/actor_system_config.hpp"
3432
#include "caf/binary_deserializer.hpp"
@@ -40,9 +38,6 @@
4038
#include "caf/detail/worker_hub.hpp"
4139
#include "caf/error.hpp"
4240
#include "caf/fwd.hpp"
43-
#include "caf/intrusive/drr_queue.hpp"
44-
#include "caf/intrusive/fifo_inbox.hpp"
45-
#include "caf/intrusive/singly_linked.hpp"
4641
#include "caf/mailbox_element.hpp"
4742
#include "caf/net/actor_proxy_impl.hpp"
4843
#include "caf/net/basp/constants.hpp"
@@ -53,18 +48,15 @@
5348
#include "caf/net/basp/worker.hpp"
5449
#include "caf/net/consumer.hpp"
5550
#include "caf/net/consumer_queue.hpp"
56-
#include "caf/net/multiplexer.hpp"
5751
#include "caf/net/receive_policy.hpp"
5852
#include "caf/net/socket_manager.hpp"
5953
#include "caf/node_id.hpp"
60-
#include "caf/policy/normal_messages.hpp"
6154
#include "caf/proxy_registry.hpp"
6255
#include "caf/response_promise.hpp"
6356
#include "caf/scoped_execution_unit.hpp"
6457
#include "caf/send.hpp"
6558
#include "caf/tag/message_oriented.hpp"
6659
#include "caf/unit.hpp"
67-
#include "caf/variant.hpp"
6860

6961
namespace caf::net::basp {
7062

@@ -96,34 +88,35 @@ class CAF_NET_EXPORT application : public consumer {
9688
error init(socket_manager* owner, LowerLayerPtr down, const settings& cfg) {
9789
// Initialize member variables.
9890
owner_ = owner;
99-
system_ = &owner->mpx().system();
91+
system_ = &owner->system();
10092
executor_.system_ptr(system_);
10193
executor_.proxy_registry_ptr(&proxies_);
94+
max_throughput_ = get_or(cfg, "caf.scheduler.max-throughput",
95+
defaults::scheduler::max_throughput);
10296
auto workers = get_or<size_t>(
10397
cfg, "caf.middleman.workers",
10498
std::min(3u, std::thread::hardware_concurrency() / 4u) + 1);
105-
max_throughput_ = get_or(system().config(), "caf.scheduler.max-throughput",
106-
defaults::scheduler::max_throughput);
10799
for (size_t i = 0; i < workers; ++i)
108100
hub_->add_new_worker(*queue_, proxies_);
109101
// Write handshake.
110-
return write_message(
111-
down, header{message_type::handshake, version}, system().node(),
112-
get_or(system().config(), "caf.middleman.app-identifiers",
113-
application::default_app_ids()));
102+
auto app_ids = get_or(cfg, "caf.middleman.app-identifiers",
103+
application::default_app_ids());
104+
return write_message(down, header{message_type::handshake, version},
105+
system().node(), app_ids);
114106
}
115107

116108
template <class LowerLayerPtr>
117109
bool prepare_send(LowerLayerPtr& down) {
110+
CAF_LOG_TRACE("");
118111
if (!handshake_complete())
119112
return true;
120113
if (auto err = dequeue_events(down)) {
121-
CAF_LOG_ERROR("handle_events failed: " << CAF_ARG(err));
114+
CAF_LOG_ERROR("dequeue_events failed: " << CAF_ARG(err));
122115
down->abort_reason(err);
123116
return false;
124117
}
125118
if (auto err = dequeue_messages(down)) {
126-
CAF_LOG_ERROR("handle_messages failed: " << CAF_ARG(err));
119+
CAF_LOG_ERROR("dequeue_messages failed: " << CAF_ARG(err));
127120
down->abort_reason(err);
128121
return false;
129122
}
@@ -132,6 +125,7 @@ class CAF_NET_EXPORT application : public consumer {
132125

133126
template <class LowerLayerPtr>
134127
ptrdiff_t consume(LowerLayerPtr& down, byte_span buffer) {
128+
CAF_LOG_TRACE(CAF_ARG2("buffer.size", buffer.size()));
135129
if (auto err = handle(down, buffer)) {
136130
CAF_LOG_ERROR("could not handle message: " << CAF_ARG(err));
137131
down->abort_reason(err);
@@ -142,13 +136,15 @@ class CAF_NET_EXPORT application : public consumer {
142136

143137
template <class LowerLayerPtr>
144138
bool done_sending(LowerLayerPtr&) {
139+
CAF_LOG_TRACE("");
145140
if (mailbox_.blocked())
146141
return true;
147142
return (mailbox_.empty() && mailbox_.try_block());
148143
}
149144

150145
template <class LowerLayerPtr>
151146
void abort(LowerLayerPtr&, const error&) {
147+
CAF_LOG_TRACE("");
152148
// nop
153149
}
154150

@@ -163,15 +159,12 @@ class CAF_NET_EXPORT application : public consumer {
163159
/// Writes a message to the message buffer of `down`.
164160
template <class LowerLayerPtr, class... Ts>
165161
error write_message(LowerLayerPtr& down, header hdr, Ts&&... xs) {
162+
CAF_LOG_TRACE(CAF_ARG(hdr));
166163
down->begin_message();
167164
auto& buf = down->message_buffer();
168165
binary_serializer sink{&executor_, buf};
169-
if (!sink.apply_object(hdr))
166+
if (!sink.apply_objects(hdr, xs...))
170167
return sink.get_error();
171-
if constexpr (sizeof...(xs) >= 1) {
172-
if (!sink.apply_objects(xs...))
173-
return sink.get_error();
174-
}
175168
down->end_message();
176169
return none;
177170
}
@@ -212,6 +205,7 @@ class CAF_NET_EXPORT application : public consumer {
212205

213206
template <class LowerLayerPtr>
214207
error dequeue_events(LowerLayerPtr& down) {
208+
CAF_LOG_TRACE("");
215209
if (!mailbox_.blocked()) {
216210
mailbox_.fetch_more();
217211
auto& q = std::get<0>(mailbox_.queue().queues());
@@ -220,14 +214,14 @@ class CAF_NET_EXPORT application : public consumer {
220214
for (auto ptr = q.next(); ptr != nullptr; ptr = q.next()) {
221215
auto f = detail::make_overload(
222216
[&](consumer_queue::event::resolve_request& x) {
223-
write_resolve_request(down, x.locator, x.listener);
217+
write_resolve_request(down, x.path, x.listener);
224218
},
225219
[&](consumer_queue::event::new_proxy& x) { new_proxy(down, x.id); },
226220
[&](consumer_queue::event::local_actor_down& x) {
227221
local_actor_down(down, x.id, std::move(x.reason));
228222
},
229223
[&](consumer_queue::event::timeout& x) {
230-
timeout(down, x.type, x.id);
224+
timeout(down, std::move(x.type), x.id);
231225
});
232226
visit(f, ptr->value);
233227
}
@@ -250,27 +244,31 @@ class CAF_NET_EXPORT application : public consumer {
250244
}
251245

252246
template <class LowerLayerPtr>
253-
void new_proxy(LowerLayerPtr& down, actor_id id) {
247+
void new_proxy(LowerLayerPtr& down, actor_id aid) {
248+
CAF_LOG_TRACE(CAF_ARG(aid));
254249
if (auto err = write_message(down, header{message_type::monitor_message,
255-
static_cast<uint64_t>(id)}))
250+
static_cast<uint64_t>(aid)}))
256251
down->abort_reason(err);
257252
}
258253

259254
template <class LowerLayerPtr>
260-
void local_actor_down(LowerLayerPtr& down, actor_id id, error reason) {
255+
void local_actor_down(LowerLayerPtr& down, actor_id aid, error reason) {
256+
CAF_LOG_TRACE(CAF_ARG(aid) << CAF_ARG(reason));
261257
if (auto err = write_message(
262-
down, header{message_type::down_message, static_cast<uint64_t>(id)},
258+
down, header{message_type::down_message, static_cast<uint64_t>(aid)},
263259
reason))
264260
down->abort_reason(err);
265261
}
266262

267263
template <class LowerLayerPtr>
268264
void timeout(LowerLayerPtr& down, std::string type, uint64_t id) {
265+
CAF_LOG_TRACE(CAF_ARG(type) << CAF_ARG(id));
269266
down->timeout(std::move(type), id);
270267
}
271268

272269
template <class LowerLayerPtr>
273270
error dequeue_messages(LowerLayerPtr& down) {
271+
CAF_LOG_TRACE("");
274272
for (size_t count = 0; count < max_throughput_; ++count) {
275273
auto ptr = next_message();
276274
if (ptr == nullptr)
@@ -376,6 +374,7 @@ class CAF_NET_EXPORT application : public consumer {
376374

377375
template <class LowerLayerPtr>
378376
error handle_actor_message(LowerLayerPtr&, header hdr, byte_span payload) {
377+
CAF_LOG_TRACE(CAF_ARG(hdr) << CAF_ARG2("payload.size", payload.size()));
379378
auto worker = hub_->pop();
380379
if (worker != nullptr) {
381380
CAF_LOG_DEBUG("launch BASP worker for deserializing an actor_message");

libcaf_net/caf/net/consumer_queue.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ class CAF_NET_EXPORT consumer_queue {
6161
class event final : public element {
6262
public:
6363
struct resolve_request {
64-
std::string locator;
64+
std::string path;
6565
actor listener;
6666
};
6767

@@ -79,7 +79,7 @@ class CAF_NET_EXPORT consumer_queue {
7979
uint64_t id;
8080
};
8181

82-
event(std::string locator, actor listener);
82+
event(std::string path, actor listener);
8383

8484
event(actor_id proxy_id);
8585

libcaf_net/caf/net/endpoint_manager_impl.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ class endpoint_manager_impl : public endpoint_manager {
9191
for (auto ptr = q.next(); ptr != nullptr; ptr = q.next()) {
9292
auto f = detail::make_overload(
9393
[&](consumer_queue::event::resolve_request& x) {
94-
transport_.resolve(*this, x.locator, x.listener);
94+
transport_.resolve(*this, x.path, x.listener);
9595
},
9696
[&](consumer_queue::event::new_proxy& x) {
9797
transport_.new_proxy(*this, x.id);

0 commit comments

Comments
 (0)