2024年9月23日

多线程问题:异常处理,单例,双重检查锁定

摘要: 1)多线程异常处理 多线程中如何捕获抛出异常到主线程 a)catch中使用std::current_exception();获得正在处理的异常 b)通过引用类型std::exception_ptr& _ex_ptr 传出 c)std::rethrow_exception(ex_ptr);重新抛出异常 阅读全文

posted @ 2024-09-23 17:25 不败剑坤 阅读(72) 评论(0) 推荐(0)

线程同步:锁,条件变量,并发

摘要: 1)锁mutex 2)条件变量 头文件<condiction_variable> condition_variable cv; cv.wait(_lock,谓语)//使用谓语检查是否满足唤醒条件,防止假唤醒 using namespace std; mutex _mutex; condition_v 阅读全文

posted @ 2024-09-23 17:23 不败剑坤 阅读(33) 评论(0) 推荐(0)

c++多线程,锁

摘要: 1)机器最大线程数 uint16_t max_thread = thread::hardware_concurrency(); 2)vector中管理线程 获取线程id a)thread::id _id=std::this_thread::get_id(); b)thread th(getSum_v 阅读全文

posted @ 2024-09-23 10:40 不败剑坤 阅读(47) 评论(0) 推荐(0)

2024年9月5日

断言assert,异常,类型转换

摘要: assert 作用:等同于Qdebug(val),判断程序是否得到自己想要的结果 可以通过#definde NDEBUG 一键屏蔽 接受一个条件表达式作为参数。如果该条件表达式的值为假(即为0或者布尔意义上的false),则assert会触发一个错误,通常会导致程序终止,并打印出错误信息和发生错误的 阅读全文

posted @ 2024-09-05 16:40 不败剑坤 阅读(55) 评论(0) 推荐(0)

2024年9月4日

常用linux命令

摘要: ls ls-l(详细信息) ls-la(列出隐藏文件) ls-la drwxrwxr-x 3 yan yan 4096 9月 4 15:59 ./ -rw-rw-r-- 1 yan yan 14068 9月 4 15:55 CMakeCache.txt drwxrwxr-x: d 表示directo 阅读全文

posted @ 2024-09-04 17:18 不败剑坤 阅读(20) 评论(0) 推荐(0)

使用Cmake-编写CMakeLists.txt 文件,vscode

摘要: 简单模板: cmake_minimum_required(VERSION 3.10) project(my_project) set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) add_executable(my_projec 阅读全文

posted @ 2024-09-04 16:03 不败剑坤 阅读(1391) 评论(0) 推荐(0)

makefile模版

摘要: # funmain:hello.cpp mymath.h mymath.cpp main.cpp # g++ -o funmain hello.cpp mymath.cpp main.cpp # Makefile for a simple C++ project # 编译器 CC = g++ # C 阅读全文

posted @ 2024-09-04 14:57 不败剑坤 阅读(94) 评论(0) 推荐(0)

导航