Skip to content

Commit

Permalink
feat(base,event,eventx): 添加了wrapped_recorder.h,用于在编译期可配置recorder.h的开关
Browse files Browse the repository at this point in the history
  • Loading branch information
hevake committed Jun 10, 2024
1 parent 4f7c0e6 commit d211109
Show file tree
Hide file tree
Showing 11 changed files with 50 additions and 8 deletions.
3 changes: 3 additions & 0 deletions config.mk
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,6 @@ MODULES += jsonrpc

## 第三方库依赖
THIRDPARTY += nlohmann

## 编译配置
CCFLAGS += -DENABLE_TRACE_RECORDER=1
3 changes: 2 additions & 1 deletion modules/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ set(TBOX_BASE_HEADERS
catch_throw.h
func_types.h
object_pool.hpp
recorder.h)
recorder.h
wrapped_recorder.h)

set(TBOX_BASE_SOURCES
version.cpp
Expand Down
1 change: 1 addition & 0 deletions modules/base/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ HEAD_FILES = \
object_pool.hpp \
func_types.h \
recorder.h \
wrapped_recorder.h \

CPP_SRC_FILES = \
version.cpp \
Expand Down
37 changes: 37 additions & 0 deletions modules/base/wrapped_recorder.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* .============.
* // M A K E / \
* // C++ DEV / \
* // E A S Y / \/ \
* ++ ----------. \/\ .
* \\ \ \ /\ /
* \\ \ \ /
* \\ \ \ /
* -============'
*
* Copyright (c) 2024 Hevake and contributors, all rights reserved.
*
* This file is part of cpp-tbox (https://github.com/cpp-main/cpp-tbox)
* Use of this source code is governed by MIT license that can be found
* in the LICENSE file in the root of the source tree. All contributing
* project authors may be found in the CONTRIBUTORS.md file in the root
* of the source tree.
*/
/**
* 在 recorder.h 的基础上加 ENABLE_TRACE_RECORDER 宏开关
* 使 recorder 功能可以在编译期间被关彻底关闭
*/
#ifndef TBOX_TRACE_WRAPPED_RECORDER_H_20240610
#define TBOX_TRACE_WRAPPED_RECORDER_H_20240610

#if ENABLE_TRACE_RECORDER
#include "recorder.h"
#else
#define RECORD_SCOPE()
#define RECORD_DEFINE(name)
#define RECORD_START(name)
#define RECORD_STOP(name)
#define RECORD_EVENT()
#endif

#endif //TBOX_TRACE_WRAPPED_RECORDER_H_20240610
2 changes: 1 addition & 1 deletion modules/event/common_loop_run.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include <algorithm>
#include <tbox/base/log.h>
#include <tbox/base/assert.h>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>

namespace tbox {
namespace event {
Expand Down
2 changes: 1 addition & 1 deletion modules/event/common_loop_timer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <algorithm>
#include <tbox/base/defines.h>
#include <tbox/base/assert.h>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>

#include "timer_event_impl.h"

Expand Down
2 changes: 1 addition & 1 deletion modules/event/engines/epoll/fd_event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
#include <tbox/base/log.h>
#include <tbox/base/assert.h>
#include <tbox/base/defines.h>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>

namespace tbox {
namespace event {
Expand Down
2 changes: 1 addition & 1 deletion modules/event/engines/epoll/loop.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include <tbox/base/log.h>
#include <tbox/base/defines.h>
#include <tbox/base/assert.h>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>

namespace tbox {
namespace event {
Expand Down
2 changes: 1 addition & 1 deletion modules/event/signal_event_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
#include "common_loop.h"
#include <tbox/base/log.h>
#include <tbox/base/assert.h>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>

namespace tbox {
namespace event {
Expand Down
2 changes: 1 addition & 1 deletion modules/eventx/thread_pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
#include <tbox/base/assert.h>
#include <tbox/base/catch_throw.h>
#include <tbox/base/object_pool.hpp>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>
#include <tbox/event/loop.h>

namespace tbox {
Expand Down
2 changes: 1 addition & 1 deletion modules/eventx/work_thread.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#include <tbox/base/catch_throw.h>
#include <tbox/base/object_pool.hpp>
#include <tbox/base/assert.h>
#include <tbox/base/recorder.h>
#include <tbox/base/wrapped_recorder.h>
#include <tbox/event/loop.h>

namespace tbox {
Expand Down

0 comments on commit d211109

Please sign in to comment.