Skip to content
This repository was archived by the owner on Jul 4, 2025. It is now read-only.

Commit fd8b588

Browse files
committed
update comment
1 parent 14ad981 commit fd8b588

File tree

4 files changed

+8
-9
lines changed

4 files changed

+8
-9
lines changed

engine/controllers/events.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
#include <drogon/PubSubService.h>
44
#include <drogon/WebSocketController.h>
55
#include <eventpp/eventqueue.h>
6+
#include <unordered_set>
67
#include "common/download_event.h"
78
#include "common/event.h"
89

@@ -40,5 +41,5 @@ class Events : public drogon::WebSocketController<Events, false> {
4041
void broadcast(const std::string& message);
4142

4243
std::shared_ptr<EventQueue> event_queue_;
43-
std::set<WebSocketConnectionPtr> connections_;
44+
std::unordered_set<WebSocketConnectionPtr> connections_;
4445
};

engine/services/download_service.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ cpp::result<bool, std::string> DownloadService::Download(
190190
CTL_INF("Existing file size: " << download_item.downloadUrl << " - "
191191
<< download_item.localPath.string()
192192
<< " - " << existing_file_size);
193-
CTL_INF("Download item size: " << download_item.bytes.value());
193+
CTL_INF("Download item size: " << download_item.bytes.value());
194194
auto missing_bytes = download_item.bytes.value() - existing_file_size;
195195
if (missing_bytes > 0 &&
196196
download_item.localPath.extension().string() != ".yaml" &&

engine/services/download_service.h

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
#include <optional>
88
#include <vector>
99
#include "common/download_event.h"
10-
#include "utils/logging_utils.h"
1110
#include "utils/result.hpp"
1211

1312
class DownloadService {
@@ -49,7 +48,7 @@ class DownloadService {
4948

5049
curl_off_t GetLocalFileSize(const std::filesystem::path& path) const;
5150

52-
std::optional<std::shared_ptr<EventQueue>> event_queue_;
51+
std::shared_ptr<EventQueue> event_queue_;
5352

5453
std::vector<std::string> download_task_list_;
5554
std::unordered_map<std::string, DownloadTask> download_task_map_;
@@ -64,9 +63,8 @@ class DownloadService {
6463

6564
static int ProgressCallback(void* ptr, double dltotal, double dlnow,
6665
double ultotal, double ulnow) {
67-
DownloadService* service = static_cast<DownloadService*>(ptr);
68-
auto event_queue = service->event_queue_.value();
69-
if (event_queue == nullptr) {
66+
auto service = static_cast<DownloadService*>(ptr);
67+
if (service->event_queue_ == nullptr) {
7068
return 0;
7169
}
7270

@@ -87,7 +85,7 @@ class DownloadService {
8785
}
8886
}
8987

90-
event_queue->enqueue(
88+
service->event_queue_->enqueue(
9189
"download-update",
9290
DownloadEvent{
9391
.type_ = cortex::event::DownloadEventType::DownloadUpdated,

engine/utils/event_processor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class EventProcessor {
1717
: event_queue_(std::move(queue)), running_(true) {
1818
thread_ = std::thread([this]() {
1919
while (running_) {
20+
event_queue_->wait();
2021
event_queue_->process();
21-
std::this_thread::sleep_for(std::chrono::milliseconds(1));
2222
}
2323
});
2424
}

0 commit comments

Comments
 (0)