Skip to content

Commit 900e021

Browse files
committed
feat(advanced_network) Lint fixes
Lint fixes Signed-off-by: Rony Rado <[email protected]>
1 parent 6ef3c0c commit 900e021

File tree

7 files changed

+208
-96
lines changed

7 files changed

+208
-96
lines changed

operators/advanced_network/advanced_network/managers/rivermax/rivermax_mgr_impl/adv_network_rivermax_mgr.cpp

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,9 @@ RivermaxMgr::RivermaxMgrImpl::~RivermaxMgrImpl() {}
368368

369369
void RivermaxMgr::RivermaxMgrImpl::run() {
370370
std::size_t num_services = rx_services_.size();
371-
if (num_services > 0) { HOLOSCAN_LOG_INFO("Starting {} RX Services", num_services); }
371+
if (num_services > 0) {
372+
HOLOSCAN_LOG_INFO("Starting {} RX Services", num_services);
373+
}
372374

373375
for (const auto& entry : rx_services_) {
374376
uint32_t key = entry.first;
@@ -378,7 +380,9 @@ void RivermaxMgr::RivermaxMgrImpl::run() {
378380
}
379381

380382
num_services = tx_services_.size();
381-
if (num_services > 0) { HOLOSCAN_LOG_INFO("Starting {} TX Services", num_services); }
383+
if (num_services > 0) {
384+
HOLOSCAN_LOG_INFO("Starting {} TX Services", num_services);
385+
}
382386

383387
for (const auto& entry : tx_services_) {
384388
uint32_t key = entry.first;
@@ -413,7 +417,8 @@ uint16_t RivermaxMgr::RivermaxMgrImpl::get_packet_length(BurstParams* burst, int
413417

414418
void* RivermaxMgr::RivermaxMgrImpl::get_packet_extra_info(BurstParams* burst, int idx) {
415419
RivermaxBurst* rivermax_burst = static_cast<RivermaxBurst*>(burst);
416-
if (rivermax_burst->is_packet_info_per_packet()) return burst->pkt_extra_info[idx];
420+
if (rivermax_burst->is_packet_info_per_packet())
421+
return burst->pkt_extra_info[idx];
417422
return nullptr;
418423
}
419424

@@ -524,7 +529,9 @@ Status RivermaxMgr::RivermaxMgrImpl::get_rx_burst(BurstParams** burst, int port,
524529
}
525530

526531
auto out_burst_shared = queue_it->second->dequeue_burst();
527-
if (out_burst_shared == nullptr) { return Status::NULL_PTR; }
532+
if (out_burst_shared == nullptr) {
533+
return Status::NULL_PTR;
534+
}
528535
*burst = out_burst_shared.get();
529536
return Status::SUCCESS;
530537
}
@@ -552,7 +559,9 @@ Status RivermaxMgr::RivermaxMgrImpl::send_tx_burst(BurstParams* burst) {
552559
}
553560

554561
void RivermaxMgr::RivermaxMgrImpl::shutdown() {
555-
if (force_quit.load()) { return; }
562+
if (force_quit.load()) {
563+
return;
564+
}
556565
HOLOSCAN_LOG_INFO("Advanced Network Rivermax manager shutting down");
557566
force_quit.store(true);
558567
print_stats();
@@ -569,10 +578,14 @@ void RivermaxMgr::RivermaxMgrImpl::shutdown() {
569578
}
570579

571580
for (auto& rx_service_thread : rx_service_threads_) {
572-
if (rx_service_thread.joinable()) { rx_service_thread.join(); }
581+
if (rx_service_thread.joinable()) {
582+
rx_service_thread.join();
583+
}
573584
}
574585
for (auto& tx_service_thread : tx_service_threads_) {
575-
if (tx_service_thread.joinable()) { tx_service_thread.join(); }
586+
if (tx_service_thread.joinable()) {
587+
tx_service_thread.join();
588+
}
576589
}
577590
HOLOSCAN_LOG_INFO("All service threads finished");
578591
rx_services_.clear();

operators/advanced_network/advanced_network/managers/rivermax/rivermax_mgr_impl/burst_manager.cpp

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,18 @@ class NonBlockingQueue : public QueueInterface<T> {
4848

4949
public:
5050
void enqueue(const T& value) override {
51-
if (stop_) { return; }
51+
if (stop_) {
52+
return;
53+
}
5254
std::lock_guard<std::mutex> lock(mutex_);
5355
queue_.push(value);
5456
}
5557

5658
bool try_dequeue(T& value) override {
5759
std::lock_guard<std::mutex> lock(mutex_);
58-
if (queue_.empty() || stop_) { return false; }
60+
if (queue_.empty() || stop_) {
61+
return false;
62+
}
5963
value = queue_.front();
6064
queue_.pop();
6165
return true;
@@ -75,9 +79,7 @@ class NonBlockingQueue : public QueueInterface<T> {
7579
while (!queue_.empty()) { queue_.pop(); }
7680
}
7781

78-
void stop() override {
79-
stop_ = true;
80-
}
82+
void stop() override { stop_ = true; }
8183
};
8284

8385
/**
@@ -94,7 +96,9 @@ class BlockingQueue : public QueueInterface<T> {
9496

9597
public:
9698
void enqueue(const T& value) override {
97-
if (stop_) { return; }
99+
if (stop_) {
100+
return;
101+
}
98102
std::lock_guard<std::mutex> lock(mutex_);
99103
queue_.push(value);
100104
cond_.notify_one();
@@ -103,7 +107,9 @@ class BlockingQueue : public QueueInterface<T> {
103107
bool try_dequeue(T& value) override {
104108
std::unique_lock<std::mutex> lock(mutex_);
105109
cond_.wait(lock, [this] { return !queue_.empty() || stop_; });
106-
if (stop_) { return false; }
110+
if (stop_) {
111+
return false;
112+
}
107113
value = queue_.front();
108114
queue_.pop();
109115
return true;
@@ -112,9 +118,11 @@ class BlockingQueue : public QueueInterface<T> {
112118
bool try_dequeue(T& value, std::chrono::milliseconds timeout) override {
113119
std::unique_lock<std::mutex> lock(mutex_);
114120
if (!cond_.wait_for(lock, timeout, [this] { return !queue_.empty() || stop_; })) {
115-
return false;
121+
return false;
122+
}
123+
if (stop_) {
124+
return false;
116125
}
117-
if (stop_) { return false; }
118126
value = queue_.front();
119127
queue_.pop();
120128
return true;
@@ -131,8 +139,8 @@ class BlockingQueue : public QueueInterface<T> {
131139
}
132140

133141
void stop() override {
134-
stop_ = true;
135-
cond_.notify_all();
142+
stop_ = true;
143+
cond_.notify_all();
136144
}
137145
};
138146

@@ -237,7 +245,7 @@ std::shared_ptr<RivermaxBurst> AnoBurstsMemoryPool::dequeue_burst() {
237245
std::shared_ptr<RivermaxBurst> burst;
238246

239247
if (queue_->try_dequeue(burst,
240-
std::chrono::milliseconds(RxBurstsManager::GET_BURST_TIMEOUT_MS))) {
248+
std::chrono::milliseconds(RxBurstsManager::GET_BURST_TIMEOUT_MS))) {
241249
return burst;
242250
}
243251
return nullptr;
@@ -278,7 +286,7 @@ std::shared_ptr<RivermaxBurst> AnoBurstsQueue::dequeue_burst() {
278286
std::shared_ptr<RivermaxBurst> burst;
279287

280288
if (queue_->try_dequeue(burst,
281-
std::chrono::milliseconds(RxBurstsManager::GET_BURST_TIMEOUT_MS))) {
289+
std::chrono::milliseconds(RxBurstsManager::GET_BURST_TIMEOUT_MS))) {
282290
return burst;
283291
}
284292
return nullptr;
@@ -420,16 +428,20 @@ RxBurstsManager::RxBurstsManager(bool send_packet_ext_info, int port_id, int que
420428
}
421429

422430
RxBurstsManager::~RxBurstsManager() {
423-
if (using_shared_out_queue_) { return; }
431+
if (using_shared_out_queue_) {
432+
return;
433+
}
424434

425435
std::shared_ptr<RivermaxBurst> burst;
426436
// Get all bursts from the queue and return them to the memory pool
427437
while (rx_bursts_out_queue_->available_bursts() > 0) {
428438
burst = rx_bursts_out_queue_->dequeue_burst();
429-
if (burst == nullptr) break;
439+
if (burst == nullptr)
440+
break;
430441
rx_bursts_mempool_->enqueue_burst(burst);
431442
}
432443
}
444+
433445
std::string RxBurstsManager::get_pool_status_string() const {
434446
uint32_t utilization = get_pool_utilization_percent();
435447
size_t available = rx_bursts_mempool_->available_bursts();

operators/advanced_network/advanced_network/managers/rivermax/rivermax_mgr_impl/burst_manager.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ class RivermaxBurst : public BurstParams {
8787
*/
8888
inline uint16_t get_burst_id() const {
8989
auto burst_info = get_burst_info();
90-
if (burst_info == nullptr) { return 0; }
90+
if (burst_info == nullptr) {
91+
return 0;
92+
}
9193
return burst_info->burst_id;
9294
}
9395

@@ -140,7 +142,9 @@ class RivermaxBurst : public BurstParams {
140142

141143
auto burst_info = get_burst_info();
142144

143-
if (burst_info == nullptr) { return; }
145+
if (burst_info == nullptr) {
146+
return;
147+
}
144148

145149
burst_info->hds_on = hds_on;
146150
burst_info->header_stride_size = header_stride_size;
@@ -164,9 +168,7 @@ class RivermaxBurst : public BurstParams {
164168
*
165169
* @return The flags of the burst.
166170
*/
167-
inline BurstFlags get_burst_flags() const {
168-
return static_cast<BurstFlags>(hdr.hdr.burst_flags);
169-
}
171+
inline BurstFlags get_burst_flags() const { return static_cast<BurstFlags>(hdr.hdr.burst_flags); }
170172

171173
/**
172174
* @brief Gets the extended info of a burst.
@@ -405,7 +407,9 @@ class RxBurstsManager {
405407

406408
auto out_burst = rx_bursts_out_queue_->dequeue_burst().get();
407409
*burst = static_cast<BurstParams*>(out_burst);
408-
if (*burst == nullptr) { return Status::NULL_PTR; }
410+
if (*burst == nullptr) {
411+
return Status::NULL_PTR;
412+
}
409413
return Status::SUCCESS;
410414
}
411415

operators/advanced_network/advanced_network/managers/rivermax/rivermax_mgr_impl/rivermax_config_manager.cpp

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,9 @@ bool RivermaxConfigContainer::parse_configuration(const NetworkConfig& cfg) {
8989
set_rivermax_log_level(cfg.log_level_);
9090

9191
if (rivermax_rx_config_found == 0 && rivermax_tx_config_found == 0) {
92-
HOLOSCAN_LOG_ERROR("Failed to parse Rivermax advanced_network settings. "
93-
"No valid settings found");
92+
HOLOSCAN_LOG_ERROR(
93+
"Failed to parse Rivermax advanced_network settings. "
94+
"No valid settings found");
9495
return false;
9596
}
9697

@@ -112,12 +113,16 @@ int RivermaxConfigContainer::parse_rx_queues(uint16_t port_id,
112113
auto rx_config_manager = std::dynamic_pointer_cast<RxConfigManager>(
113114
get_config_manager(RivermaxConfigContainer::ConfigType::RX));
114115

115-
if (!rx_config_manager) { return 0; }
116+
if (!rx_config_manager) {
117+
return 0;
118+
}
116119

117120
rx_config_manager->set_configuration(cfg_);
118121

119122
for (const auto& q : queues) {
120-
if (!rx_config_manager->append_candidate_for_rx_queue(port_id, q)) { continue; }
123+
if (!rx_config_manager->append_candidate_for_rx_queue(port_id, q)) {
124+
continue;
125+
}
121126
rivermax_rx_config_found++;
122127
}
123128

@@ -208,7 +213,9 @@ bool RxConfigManager::append_ipo_receiver_candidate_for_rx_queue(
208213
return false;
209214
}
210215

211-
if (config_memory_allocator(rivermax_rx_config, q) == false) { return false; }
216+
if (config_memory_allocator(rivermax_rx_config, q) == false) {
217+
return false;
218+
}
212219

213220
rivermax_rx_config.cpu_cores = q.common_.cpu_core_;
214221
rivermax_rx_config.master_core = cfg_.common_.master_core_;
@@ -239,7 +246,9 @@ bool RxConfigManager::append_rtp_receiver_candidate_for_rx_queue(
239246
return false;
240247
}
241248

242-
if (config_memory_allocator(rivermax_rx_config, q) == false) { return false; }
249+
if (config_memory_allocator(rivermax_rx_config, q) == false) {
250+
return false;
251+
}
243252

244253
rivermax_rx_config.cpu_cores = q.common_.cpu_core_;
245254
rivermax_rx_config.master_core = cfg_.common_.master_core_;
@@ -270,12 +279,16 @@ int RivermaxConfigContainer::parse_tx_queues(uint16_t port_id,
270279
auto tx_config_manager = std::dynamic_pointer_cast<TxConfigManager>(
271280
get_config_manager(RivermaxConfigContainer::ConfigType::TX));
272281

273-
if (!tx_config_manager) { return 0; }
282+
if (!tx_config_manager) {
283+
return 0;
284+
}
274285

275286
tx_config_manager->set_configuration(cfg_);
276287

277288
for (const auto& q : queues) {
278-
if (!tx_config_manager->append_candidate_for_tx_queue(port_id, q)) { continue; }
289+
if (!tx_config_manager->append_candidate_for_tx_queue(port_id, q)) {
290+
continue;
291+
}
279292
rivermax_tx_config_found++;
280293
}
281294

@@ -355,7 +368,9 @@ bool TxConfigManager::append_media_sender_candidate_for_tx_queue(
355368
return false;
356369
}
357370

358-
if (config_memory_allocator(rivermax_tx_config, q) == false) { return false; }
371+
if (config_memory_allocator(rivermax_tx_config, q) == false) {
372+
return false;
373+
}
359374

360375
rivermax_tx_config.cpu_cores = q.common_.cpu_core_;
361376
rivermax_tx_config.master_core = cfg_.common_.master_core_;
@@ -657,8 +672,7 @@ bool RivermaxConfigParser::parse_common_tx_settings(
657672
rivermax_tx_config.print_parameters = tx_settings["verbose"].as<bool>(false);
658673
rivermax_tx_config.num_of_threads = tx_settings["num_of_threads"].as<size_t>(1);
659674
rivermax_tx_config.send_packet_ext_info = tx_settings["send_packet_ext_info"].as<bool>(true);
660-
rivermax_tx_config.num_of_packets_in_chunk =
661-
tx_settings["num_of_packets_in_chunk"].as<size_t>(
675+
rivermax_tx_config.num_of_packets_in_chunk = tx_settings["num_of_packets_in_chunk"].as<size_t>(
662676
MediaSenderSettings::DEFAULT_NUM_OF_PACKETS_IN_CHUNK_FHD);
663677
rivermax_tx_config.sleep_between_operations =
664678
tx_settings["sleep_between_operations"].as<bool>(true);
@@ -679,9 +693,8 @@ bool RivermaxConfigParser::parse_media_sender_settings(
679693
rivermax_tx_config.use_internal_memory_pool =
680694
tx_settings["use_internal_memory_pool"].as<bool>(false);
681695
if (rivermax_tx_config.use_internal_memory_pool) {
682-
rivermax_tx_config.memory_pool_location =
683-
GetMemoryKindFromString(tx_settings["memory_pool_location"].template
684-
as<std::string>("device"));
696+
rivermax_tx_config.memory_pool_location = GetMemoryKindFromString(
697+
tx_settings["memory_pool_location"].template as<std::string>("device"));
685698
if (rivermax_tx_config.memory_pool_location == MemoryKind::INVALID) {
686699
rivermax_tx_config.memory_pool_location = MemoryKind::DEVICE;
687700
HOLOSCAN_LOG_ERROR("Invalid memory pool location, setting to DEVICE");
@@ -786,7 +799,9 @@ bool ConfigManagerUtilities::validate_cores(const std::string& cores) {
786799
void ConfigManagerUtilities::set_allocator_type(AppSettings& app_settings_config,
787800
const std::string& allocator_type) {
788801
auto setAllocatorType = [&](const std::string& allocatorTypeStr, AllocatorTypeUI allocatorType) {
789-
if (allocator_type == allocatorTypeStr) { app_settings_config.allocator_type = allocatorType; }
802+
if (allocator_type == allocatorTypeStr) {
803+
app_settings_config.allocator_type = allocatorType;
804+
}
790805
};
791806

792807
app_settings_config.allocator_type = AllocatorTypeUI::Auto;

0 commit comments

Comments
 (0)