c++ - Mongoose 网络服务器获取当前工作线程

标签 c++ c linux mongoose-web-server

我正在使用 x 线程启动 mongoose 网络服务器。 有没有一种方法可以在所有 x 个线程都忙时进行记录,以便在需要时增加线程数?

最佳答案

如果不更改 Mongoose 的代码,这是不可能的。例如,我会更改 mongoose.c 中的 static void worker_thread(struct mg_context *ctx) 函数:

  1. 当工作线程在 while 循环 while (consume_socket(ctx, &conn->client)) 内时,您可以认为工作线程很忙。
  2. close_connection(conn); 之后,工作线程可以自由处理套接字队列中的新事件。

您可以使用该点来计算繁忙线程的数量。

关于c++ - Mongoose 网络服务器获取当前工作线程,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10494266/

相关文章:

c++ - 使用三元表达式返回引用会导致运行时错误

c++ - 双向链表,按顺序添加节点

c - 有 n 个节点的 AVL 树的最大可能高度是多少

c - 这个指针应该这样操作吗?基础C

linux - 实现Java数据分析工具时的Bash错误

c++ - C/C++ : Compressing(gz) data without using temporary file

c++ - 使第一个模板参数可选

c - 错误 c2059 : syntax error: constant in c while reading from a file

linux - Bash hashmap 使用引号作为键

python - PySide2 找不到 Qt_5.15