Measure uasync CPU load and display it in desktop and Android GUIs
Sample thread CPU usage without waking idle loops, expose a one-second moving average, and refresh compact GUI indicators at 3 Hz while visible on Android. Add load and bridge regression coverage, streaming notes, and task list cleanup.
This commit is contained in:
1 parent
bcfe7ca4c1
commit
71d19013c0
25 files changed
+692
-587
No files matched your search
@@ -14,6 +14,7 @@ extern "C" {
|
||||
#include "../../../src/routing_layer/topo_group.h"
|
||||
#include "../../../src/member_files/protocol.h"
|
||||
#include "../../../src/chat/chat_member.h"
|
||||
#include "../../../src/chat/chat_core.h"
|
||||
}
|
||||
|
||||
/* ── Внутренний объект-приёмник в GUI-потоке ── */
|
||||
@@ -37,6 +38,7 @@ static gui_auto_connect_status_fn g_auto_connect_status_cb = nullptr;
|
||||
static gui_channel_peers_online_fn g_channel_peers_online_cb = nullptr;
|
||||
static gui_db_ready_fn g_db_ready_cb = nullptr;
|
||||
static gui_status_refresh_fn g_status_refresh_cb = nullptr;
|
||||
static gui_cpu_load_fn g_cpu_load_cb = nullptr;
|
||||
static gui_attachment_downloaded_fn g_attachment_downloaded_cb = nullptr;
|
||||
static gui_download_progress_fn g_download_progress_cb = nullptr;
|
||||
static gui_nodeinfo_update_fn g_nodeinfo_update_cb = nullptr;
|
||||
@@ -89,6 +91,12 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
|
||||
eventType == 16 || eventType == 17 || eventType == 24 || eventType == 25 || eventType == 31 || eventType == 33))
|
||||
g_network_changed_cb(eventType);
|
||||
switch (eventType) {
|
||||
case CHAT_EVT_CPU_LOAD:
|
||||
if (dlen != 2 || d[0] > 1 || d[1] > 100) {
|
||||
DEBUG_WARN(DEBUG_CATEGORY_SYS, "invalid CPU load response bytes=%d", dlen);
|
||||
if (g_cpu_load_cb) g_cpu_load_cb(0);
|
||||
} else if (g_cpu_load_cb) g_cpu_load_cb(d[0] ? d[1] : 0);
|
||||
break;
|
||||
case CHAT_EVT_MSG_SUBMITTED:
|
||||
if (dlen != 9 || d[8] > 1) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "invalid submission result bytes=%d", dlen); break; }
|
||||
if (g_msg_submitted_cb) g_msg_submitted_cb(d, dlen);
|
||||
@@ -497,6 +505,19 @@ void gui_bridge_set_status_refresh_cb(gui_status_refresh_fn cb) {
|
||||
g_status_refresh_cb = cb;
|
||||
}
|
||||
|
||||
void gui_bridge_set_cpu_load_cb(gui_cpu_load_fn cb) {
|
||||
g_cpu_load_cb = cb;
|
||||
}
|
||||
|
||||
int gui_bridge_request_cpu_load(void) {
|
||||
if (!g_ua || !g_inst) return 0;
|
||||
auto* task = (struct posted_task*)u_calloc(1, sizeof(struct posted_task));
|
||||
if (!task) { DEBUG_ERROR(DEBUG_CATEGORY_SYS, "CPU load request allocation failed"); return 0; }
|
||||
task->callback = chat_core_collect_cpu_load_trampoline; task->arg = g_inst;
|
||||
uasync_post_reserved(g_ua, task);
|
||||
return 1;
|
||||
}
|
||||
|
||||
void gui_bridge_set_attachment_downloaded_cb(gui_attachment_downloaded_fn cb) {
|
||||
g_attachment_downloaded_cb = cb;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user