WIP: add_sync_containers #1

Draft
tqcq wants to merge 3 commits from feat/add_sync_containers into develop
4 changed files with 11 additions and 18 deletions

1
.gitignore vendored
View File

@ -4,3 +4,4 @@ build/
compile_commands.json
.gdb_history
.cmake.conf
third_party/

View File

@ -223,26 +223,8 @@ if((CMAKE_SYSTEM_PROCESSOR MATCHES "riscv64") OR (CMAKE_SYSTEM_PROCESSOR MATCHES
endif()
endif()
# set(LIB_NAMES tile)
#
# if(("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux") OR (MINGW) OR (HAIKU) OR
# ("${CMAKE_SYSTEM_NAME}" STREQUAL "FreeBSD") OR ("${CMAKE_SYSTEM_NAME}"
# STREQUAL "GNU") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "OpenBSD") OR
# ("${CMAKE_SYSTEM_NAME}" STREQUAL "Fuchsia") OR ("${CMAKE_SYSTEM_NAME}"
# STREQUAL "DragonFly") OR ("${CMAKE_SYSTEM_NAME}" STREQUAL "SunOS")) # FIXME:
# It should be "GNU ld # for elf" set(LIB_NAMES -Wl,--whole-archive ${LIB_NAMES}
# -Wl,--no-whole-archive) elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
# set(LIB_NAMES -Wl,-all_load ${LIB_NAMES}) endif()
add_library(tile::tile ALIAS tile)
# add_library(tile SHARED $<TARGET_OBJECTS:tile>) target_include_directories(
# tile PUBLIC "${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmt/include"
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/glog"
# "${CMAKE_CURRENT_SOURCE_DIR}/third_party/glog/src"
# "${CMAKE_CURRENT_SOURCE_DIR}" RPIVATE
# "${CMAKE_CURRENT_BINARY_DIR}/third_party/gflags/include")
# target_link_libraries( tile PRIVATE ${WHOLE_ARCHIVE_PREFIX} gflags::gflags
# glog::glog libcurl fmt::fmt ${NO_WHOLE_ARCHIVE_PREFIX})
if(TILE_BUILD_TESTS)
enable_testing()

View File

@ -5,4 +5,7 @@
- [ ] 支持UDP
- [ ] 支持TCP
## 同步容器
- [ ] queue

View File

@ -32,6 +32,7 @@ namespace tile {
namespace {
std::atomic<bool> g_quit_siganl{false};
std::atomic<bool> g_tile_running{false};
void
QuitSignalHandler(int sig)
@ -58,6 +59,11 @@ InstallQuitSignalHandler()
int
Start(int argc, char **argv, std::function<int(int, char **)> cb, bool single_thread, bool enable_crash_catch)
{
{
bool expected = false;
TILE_CHECK(g_tile_running.compare_exchange_strong(expected, true), "tile already running.");
}
if (enable_crash_catch) {
// TODO: Add InstallFailureSignalHandler
// google::InstallFailureSignalHandler();
@ -139,6 +145,7 @@ void
Init(int argc, char **argv, std::function<int(int, char **)> cb)
{
std::unique_lock<std::mutex> _(init_lock);
TILE_CHECK(g_tile_running.load() == false, "tile already running.");
assert(lib_thread && "ReInitialize!!!");
const char *my_argv[1] = {"unknown"};