摘要:
创建型-简单工厂模式 //简单工厂模式 //1.增加新的功能是通过修改源代码实现,不符合开闭原则 //2.这个类职责过重,这个类发生问题,会影响很多使用这个工厂的模块 #include <iostream> using namespace std; //抽象水果类 class Fruit{ publ 阅读全文
posted @ 2023-10-14 19:04
洋綮
阅读(8)
评论(0)
推荐(0)
摘要:
高性能C++之无锁队列 lock_free_queue.h #pragma once #include <atomic> #include <vector> #include <cstddef> template<typename T, size_t N = 1024> class LockFree 阅读全文
posted @ 2023-10-14 17:30
洋綮
阅读(434)
评论(0)
推荐(0)
摘要:
对象池设计与实现 object_pool.h #ifndef _CELL_OBJECT_POOL_H_ #define _CELL_OBJECT_POOL_H_ #include<stdlib.h> #include<assert.h> #include<mutex> #ifdef _DEBUG # 阅读全文
posted @ 2023-10-14 13:23
洋綮
阅读(11)
评论(0)
推荐(0)
摘要:
内存池设计与实现 alloctor.h #ifndef _ALLOCTOR_H_ #define _ALLOCTOR_H_ void* operator new(size_t size); void operator delete(void* p); void* operator new[](siz 阅读全文
posted @ 2023-10-14 13:21
洋綮
阅读(33)
评论(0)
推荐(0)
摘要:
基于C++11 通用线程池 thread_pool.h #ifndef _PTHREAD_H_ #define _PTHREAD_H_ #include <iostream> #include <queue> #include <vector> #include <future> class Pth 阅读全文
posted @ 2023-10-14 09:18
洋綮
阅读(15)
评论(0)
推荐(0)