Skip to content

Commit d211109

Browse files
committed
feat(base,event,eventx): 添加了wrapped_recorder.h,用于在编译期可配置recorder.h的开关
1 parent 4f7c0e6 commit d211109

File tree

11 files changed

+50
-8
lines changed

11 files changed

+50
-8
lines changed

config.mk

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,6 @@ MODULES += jsonrpc
4242

4343
## 第三方库依赖
4444
THIRDPARTY += nlohmann
45+
46+
## 编译配置
47+
CCFLAGS += -DENABLE_TRACE_RECORDER=1

modules/base/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ set(TBOX_BASE_HEADERS
4545
catch_throw.h
4646
func_types.h
4747
object_pool.hpp
48-
recorder.h)
48+
recorder.h
49+
wrapped_recorder.h)
4950

5051
set(TBOX_BASE_SOURCES
5152
version.cpp

modules/base/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ HEAD_FILES = \
4545
object_pool.hpp \
4646
func_types.h \
4747
recorder.h \
48+
wrapped_recorder.h \
4849

4950
CPP_SRC_FILES = \
5051
version.cpp \

modules/base/wrapped_recorder.h

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* .============.
3+
* // M A K E / \
4+
* // C++ DEV / \
5+
* // E A S Y / \/ \
6+
* ++ ----------. \/\ .
7+
* \\ \ \ /\ /
8+
* \\ \ \ /
9+
* \\ \ \ /
10+
* -============'
11+
*
12+
* Copyright (c) 2024 Hevake and contributors, all rights reserved.
13+
*
14+
* This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox)
15+
* Use of this source code is governed by MIT license that can be found
16+
* in the LICENSE file in the root of the source tree. All contributing
17+
* project authors may be found in the CONTRIBUTORS.md file in the root
18+
* of the source tree.
19+
*/
20+
/**
21+
* 在 recorder.h 的基础上加 ENABLE_TRACE_RECORDER 宏开关
22+
* 使 recorder 功能可以在编译期间被关彻底关闭
23+
*/
24+
#ifndef TBOX_TRACE_WRAPPED_RECORDER_H_20240610
25+
#define TBOX_TRACE_WRAPPED_RECORDER_H_20240610
26+
27+
#if ENABLE_TRACE_RECORDER
28+
#include "recorder.h"
29+
#else
30+
#define RECORD_SCOPE()
31+
#define RECORD_DEFINE(name)
32+
#define RECORD_START(name)
33+
#define RECORD_STOP(name)
34+
#define RECORD_EVENT()
35+
#endif
36+
37+
#endif //TBOX_TRACE_WRAPPED_RECORDER_H_20240610

modules/event/common_loop_run.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
#include <algorithm>
2525
#include <tbox/base/log.h>
2626
#include <tbox/base/assert.h>
27-
#include <tbox/base/recorder.h>
27+
#include <tbox/base/wrapped_recorder.h>
2828

2929
namespace tbox {
3030
namespace event {

modules/event/common_loop_timer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <algorithm>
2323
#include <tbox/base/defines.h>
2424
#include <tbox/base/assert.h>
25-
#include <tbox/base/recorder.h>
25+
#include <tbox/base/wrapped_recorder.h>
2626

2727
#include "timer_event_impl.h"
2828

modules/event/engines/epoll/fd_event.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include <tbox/base/log.h>
2626
#include <tbox/base/assert.h>
2727
#include <tbox/base/defines.h>
28-
#include <tbox/base/recorder.h>
28+
#include <tbox/base/wrapped_recorder.h>
2929

3030
namespace tbox {
3131
namespace event {

modules/event/engines/epoll/loop.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
#include <tbox/base/log.h>
3333
#include <tbox/base/defines.h>
3434
#include <tbox/base/assert.h>
35-
#include <tbox/base/recorder.h>
35+
#include <tbox/base/wrapped_recorder.h>
3636

3737
namespace tbox {
3838
namespace event {

modules/event/signal_event_impl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
#include "common_loop.h"
2222
#include <tbox/base/log.h>
2323
#include <tbox/base/assert.h>
24-
#include <tbox/base/recorder.h>
24+
#include <tbox/base/wrapped_recorder.h>
2525

2626
namespace tbox {
2727
namespace event {

modules/eventx/thread_pool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535
#include <tbox/base/assert.h>
3636
#include <tbox/base/catch_throw.h>
3737
#include <tbox/base/object_pool.hpp>
38-
#include <tbox/base/recorder.h>
38+
#include <tbox/base/wrapped_recorder.h>
3939
#include <tbox/event/loop.h>
4040

4141
namespace tbox {

0 commit comments

Comments
 (0)