摘要: 概念&定义: 在 Go 中,如果一个操作 A happens-before 操作 B,则意味着: A 的结果对于 B 是可见的。 B 的执行可以依赖于 A 的执行结果。 Happens-Before 规则: 1)Goroutine启动: go语句happens-before函数的第一个语句。 2)管 阅读全文
posted @ 2024-11-08 10:16 fchy822 阅读(11) 评论(0) 推荐(0) 编辑
摘要: LRU: https://javap.blog.csdn.net/article/details/133889335 LFU: https://blog.csdn.net/qq_32099833/article/details/133889357 阅读全文
posted @ 2024-04-19 16:12 fchy822 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 一、概念(Concepts):为模板编程提供了更清晰的约束和检查机制。 template <typename T> concept Integral = std::is_integral_v<T>; // Integral约定类型T必须是整形 // std::is_integral_v<T> 等价于 阅读全文
posted @ 2024-04-11 17:40 fchy822 阅读(139) 评论(0) 推荐(0) 编辑
摘要: 分类类型特征描述C++标准_v写法(C++17) 基本类型特性检查 std::is_same<T1, T2>::value 检查两个类型是否相同 C++11 std::is_same_v<T1, T2> std::is_integral<T>::value 检查T是否为整数类型 C++11 std: 阅读全文
posted @ 2024-04-11 14:52 fchy822 阅读(39) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/zzy979481894/article/details/130981693 阅读全文
posted @ 2024-04-09 14:20 fchy822 阅读(1) 评论(0) 推荐(0) 编辑
摘要: template<typename T> class threadsafe_list { struct node // 1 { std::mutex m; std::shared_ptr<T> data; std::unique_ptr<node> next; node(): // 2 next() 阅读全文
posted @ 2024-04-02 17:53 fchy822 阅读(1) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <mutex> #include <condition_variable> #include <thread> template<typename T> class ThreadSafeQueue { private: struct Node 阅读全文
posted @ 2024-04-02 16:18 fchy822 阅读(2) 评论(0) 推荐(0) 编辑
摘要: class ThreadSafeLinkedStack { private: struct Node { T data; std::shared_ptr<Node> next; Node(T data) : data(data), next(nullptr) {} }; std::shared_pt 阅读全文
posted @ 2024-04-02 10:49 fchy822 阅读(5) 评论(0) 推荐(0) 编辑
摘要: 内存屏障,也称为内存栅栏、内存栅障或屏障指令,是一类同步屏障指令。它是CPU或编译器在对内存随机访问的操作中的一个同步点,确保此点之前的所有读写操作都执行完毕后,才可以开始执行此点之后的操作。 1)原子性(Atomicity): 原子性是指一个或多个操作作为一个整体来执行,中途不会被其他线程打断。在 阅读全文
posted @ 2024-04-01 14:35 fchy822 阅读(33) 评论(0) 推荐(0) 编辑
摘要: 一、回溯模板时刻铭记于心 // backtrace: // if 满足条件: // 添加到结果集 // return // for elem in 可选: // 选择 // backtrace() // 退回选择 二、回溯思想 ### 回朔法的思想: 回朔法的重要思想在于: 通过枚举法,对所有可能性 阅读全文
posted @ 2022-09-29 15:19 fchy822 阅读(53) 评论(0) 推荐(0) 编辑