Skip to content
This repository has been archived by the owner on Jun 23, 2022. It is now read-only.

refactor: decouple sys_exit_type with dsn_runtime #529

Merged
merged 9 commits into from
Jul 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 4 additions & 15 deletions include/dsn/tool-api/global_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@
* xxxx-xx-xx, author, fix bug about xxx
*/

/// Attention: There are some types which are defined in dsn_runtime being used in this file,
/// so this file is coupled with dsn_runtime. If you want to add some variables/types here or
/// include this file, please make sure whether you want to couple with dsn_runtime or not.

#pragma once

#include <dsn/tool-api/task_spec.h>
Expand Down Expand Up @@ -195,20 +199,5 @@ CONFIG_FLD_STRING(semaphore_factory_name, "", "semaphore provider")
CONFIG_FLD_STRING(logging_factory_name, "", "logging provider")
CONFIG_END

enum sys_exit_type
{
SYS_EXIT_NORMAL,
SYS_EXIT_BREAK, // Ctrl-C/Break,Shutdown,LogOff, see SetConsoleCtrlHandler
SYS_EXIT_EXCEPTION,

SYS_EXIT_INVALID
};

ENUM_BEGIN(sys_exit_type, SYS_EXIT_INVALID)
ENUM_REG(SYS_EXIT_NORMAL)
ENUM_REG(SYS_EXIT_BREAK)
ENUM_REG(SYS_EXIT_EXCEPTION)
ENUM_END(sys_exit_type)

extern const char *FLAGS_aio_factory_name;
} // namespace dsn
3 changes: 1 addition & 2 deletions include/dsn/tool_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ Component providers define the interface for the local components (e.g., network
#pragma once

// providers
#include <dsn/tool-api/global_config.h>
#include <dsn/utility/factory_store.h>
#include <dsn/tool-api/task_queue.h>
#include <dsn/tool-api/task_worker.h>
Expand All @@ -61,6 +60,7 @@ Component providers define the interface for the local components (e.g., network
#include <dsn/tool-api/message_parser.h>
#include <dsn/tool-api/logging_provider.h>
#include <dsn/tool-api/timer_service.h>
#include <dsn/utility/sys_exit_hook.h>

namespace dsn {
namespace tools {
Expand Down Expand Up @@ -158,7 +158,6 @@ DSN_API toollet *get_toollet(const char *name, ::dsn::provider_type type);
*/
DSN_API extern join_point<void> sys_init_before_app_created;
DSN_API extern join_point<void> sys_init_after_app_created;
DSN_API extern join_point<void, sys_exit_type> sys_exit;
/*@}*/

template <typename T>
Expand Down
30 changes: 30 additions & 0 deletions include/dsn/utility/sys_exit_hook.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// Copyright (c) 2018, Xiaomi, Inc. All rights reserved.
// This source code is licensed under the Apache License Version 2.0, which
// can be found in the LICENSE file in the root directory of this source tree.

#pragma once

#include <dsn/utility/enum_helper.h>

namespace dsn {

enum sys_exit_type
{
SYS_EXIT_NORMAL,
SYS_EXIT_BREAK, // Ctrl-C/Break,Shutdown,LogOff, see SetConsoleCtrlHandler
SYS_EXIT_EXCEPTION,

SYS_EXIT_INVALID
};

ENUM_BEGIN(sys_exit_type, SYS_EXIT_INVALID)
ENUM_REG(SYS_EXIT_NORMAL)
ENUM_REG(SYS_EXIT_BREAK)
ENUM_REG(SYS_EXIT_EXCEPTION)
ENUM_END(sys_exit_type)

namespace tools {
DSN_API extern join_point<void, sys_exit_type> sys_exit;
}

} // namespace dsn
3 changes: 0 additions & 3 deletions src/core/core/logging.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,8 @@
* THE SOFTWARE.
*/

#include <dsn/service_api_c.h>
#include <dsn/tool-api/command_manager.h>
#include <dsn/tool-api/logging_provider.h>
#include <dsn/tool_api.h>
#include "service_engine.h"
#include <dsn/tool-api/auto_codes.h>
#include <dsn/utility/flags.h>
#include <dsn/utility/smart_pointers.h>
Expand Down