摘要: 创建型-简单工厂模式 //简单工厂模式 //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)
摘要: ## 跳表 > 跳表(Skiplist)是一种多层级链表,相比一般的链表,有更高的查找效率,可比拟二叉查找树,平均期望的查找、插入、删除时间复杂度都是O(logn)。 跳表:解决单链表查询效率慢的问题 跳表vs红黑树, 1. 跳表和红黑树的插入、删除、查找效率都是O(logN),都可以顺序遍历所有元 阅读全文
posted @ 2023-08-23 21:35 洋綮 阅读(21) 评论(0) 推荐(0)
摘要: Docker Ubuuntu Docker 包括三个基本概念: 镜像(Image):Docker 镜像(Image),就相当于是一个 root 文件系统。比如官方镜像 ubuntu:16.04 就包含了完整的一套 Ubuntu16.04 最小系统的 root 文件系统。 容器(Container): 阅读全文
posted @ 2023-08-23 00:19 洋綮 阅读(13) 评论(1) 推荐(0)
摘要: ### Docker 安装 Nginx Nginx镜像库地址:https://hub.docker.com/_/nginx?tab=tags ①拉取最新版镜像 ```bash docker pull nginx:latest ``` ②查看拉取的 nginx 镜像 ```bash docker im 阅读全文
posted @ 2023-08-23 00:18 洋綮 阅读(33) 评论(0) 推荐(0)
摘要: ## C++11 智能指针 C++11 引入了 3 个智能指针类型: 1. `std::unique_ptr` :独占资源所有权的指针。 2. `std::shared_ptr` :共享资源所有权的指针。 3. `std::weak_ptr` :共享资源的观察者,需要和 std::shared_pt 阅读全文
posted @ 2023-08-22 20:12 洋綮 阅读(33) 评论(0) 推荐(0)
摘要: # Docker 从中央仓库拉取镜像到本地、使用镜像运行容器 - 安装**Docker依赖**,需要先将依赖环境全部下载,就像Maven依赖JDK一样 ``` yum -y install yum-utils device-mapper-persistent-data lvm2 ``` - **指定 阅读全文
posted @ 2023-08-22 18:01 洋綮 阅读(5) 评论(0) 推荐(0)