摘要: 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 阅读(1) 评论(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 阅读(7) 评论(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 阅读(3) 评论(0) 推荐(0) 编辑
摘要: https://blog.csdn.net/zzy979481894/article/details/130981693 阅读全文
posted @ 2024-04-09 14:21 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 阅读(1) 评论(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:50 fchy822 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 内存屏障,也称为内存栅栏、内存栅障或屏障指令,是一类同步屏障指令。它是CPU或编译器在对内存随机访问的操作中的一个同步点,确保此点之前的所有读写操作都执行完毕后,才可以开始执行此点之后的操作。 1)原子性(Atomicity): 原子性是指一个或多个操作作为一个整体来执行,中途不会被其他线程打断。在 阅读全文
posted @ 2024-04-01 14:35 fchy822 阅读(2) 评论(0) 推荐(0) 编辑
摘要: 一、回溯模板时刻铭记于心 // backtrace: // if 满足条件: // 添加到结果集 // return // for elem in 可选: // 选择 // backtrace() // 退回选择 二、回溯思想 ### 回朔法的思想: 回朔法的重要思想在于: 通过枚举法,对所有可能性 阅读全文
posted @ 2022-09-29 15:19 fchy822 阅读(45) 评论(0) 推荐(0) 编辑
摘要: package main import "fmt" import "sync" import "sync/atomic" //可以用来写单例模式和一些初始化工作等 var once sync.Once //父线程调用Add方法来设定应等待的线程的数量。 //每个被等待的线程在结束时应调用Done方法 阅读全文
posted @ 2022-04-28 18:33 fchy822 阅读(29) 评论(0) 推荐(0) 编辑