Skip to content

Commit adcda1b

Browse files
committed
Merge branch 'develop'
2 parents 1088f1c + e2baa0e commit adcda1b

16 files changed

Lines changed: 717 additions & 129 deletions

File tree

examples/http/server/file_download/file_download.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@
4040
#include <tbox/util/fs.h>
4141
#include <tbox/trace/sink.h>
4242

43+
//! 是否采用外部线程池,不需要则屏蔽之
44+
#define USE_THREAD_POOL 1
45+
46+
#if USE_THREAD_POOL
47+
#include <tbox/eventx/thread_pool.h>
48+
#endif
49+
4350
using namespace std;
4451
using namespace tbox;
4552
using namespace tbox::event;
@@ -120,6 +127,13 @@ int main(int argc, char **argv)
120127
}
121128
);
122129

130+
#if USE_THREAD_POOL
131+
tbox::eventx::ThreadPool thread_pool(sp_loop);
132+
thread_pool.initialize(2);
133+
#endif
134+
135+
::signal(SIGPIPE, SIG_IGN);
136+
123137
// 初始化信号处理
124138
sp_sig_event->initialize({SIGINT, SIGTERM}, Event::Mode::kPersist);
125139
sp_sig_event->enable();
@@ -136,7 +150,12 @@ int main(int argc, char **argv)
136150

137151
// 创建路由器和文件下载中间件
138152
RouterMiddleware router;
153+
154+
#if USE_THREAD_POOL
155+
FileDownloaderMiddleware file_downloader(sp_loop, &thread_pool);
156+
#else
139157
FileDownloaderMiddleware file_downloader(sp_loop);
158+
#endif
140159

141160
// 添加状态页面路由
142161
router.get("/api/status", [](ContextSptr ctx, const NextFunc& next) {

modules/eventx/timeout_monitor_test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ TEST(TimeoutMonitor, Clear)
7575
sp_timer->enable();
7676

7777
bool run = false;
78-
tm.setCallback([&] (int value) {
78+
tm.setCallback([&] (int /*value*/) {
7979
run = true;
8080
});
8181

0 commit comments

Comments
 (0)