摘要: #ifndef _SYNC_SIMPLEQUEUE_QUEUE_HPP_ #define _SYNC_SIMPLEQUEUE_QUEUE_HPP_ #include <queue> using namespace std; namespace utility { #ifndef _SYNC_SIMP 阅读全文
posted @ 2023-07-03 10:45 花花公子1234 阅读(295) 评论(0) 推荐(0)
摘要: class log_work { private: int log_id_ = 1; int log_level_; qnx_slog2() = default; virtual ~qnx_slog2() { uninit(); } public: inline static log_work& g 阅读全文
posted @ 2023-05-11 11:30 花花公子1234 阅读(194) 评论(0) 推荐(0)
摘要: #include <iostream> #include <sstream> #include <string> #include <tuple> #include <type_traits> template <typename T> void print_impl(std::ostringstr 阅读全文
posted @ 2023-05-11 11:08 花花公子1234 阅读(159) 评论(0) 推荐(0)
摘要: 1,编译宏做开关; #ifdef XXX ...; #else ...; #endif 2,自定义日志格式; #define FACEID_TRACE(log_str, ...) 阅读全文
posted @ 2023-05-11 10:29 花花公子1234 阅读(109) 评论(0) 推荐(0)
摘要: try { xxx core; } catch (std::exception & e) { printf("error is %s\n", e.what()); } 阅读全文
posted @ 2023-05-10 21:06 花花公子1234 阅读(81) 评论(0) 推荐(0)
摘要: #pragma once #include <string> #include <unordered_map> #include <vector> struct Node{ int fail; std::string change_word; std::string word; using Tran 阅读全文
posted @ 2021-12-30 15:49 花花公子1234 阅读(48) 评论(0) 推荐(0)
摘要: 1,工厂模式 2,单例模式 不支持拷贝构造和operator = 接口 3,观察者模式 4,访问者模式; 阅读全文
posted @ 2021-07-20 09:23 花花公子1234 阅读(30) 评论(1) 推荐(0)
摘要: (1)栈区 :函数内的临时变量; (2)堆区 :动态申请的内存,new; (3)全局区/静态区 : 全局变量和静态全局变量的存储方式是一样的,区别在于,全局变量在整个源代码中都可以使用,而静态全局变量只能在当前文件中有效(对于全局变量,加上 static 只是改变了变量的作用范围, 而对于某个局部静 阅读全文
posted @ 2021-07-19 14:53 花花公子1234 阅读(31) 评论(0) 推荐(0)
摘要: 1. 不使用sizeof()计算机器位数; int* a[2]; int size = (char*)&a[1] - (char*)&a[0]; 2. 32位指针4字节,64位指针8字节; 编译器G++, 机器64位,经测试类中的数据会向最大的字节数看齐;例如: 1. class A{ char a 阅读全文
posted @ 2021-07-12 21:01 花花公子1234 阅读(56) 评论(0) 推荐(0)
摘要: 1, 每一个节点都有三个状态:leader,follower,dead; 每一个集群在某一时间,只能有一个leader(否则会脑裂); 选主:leader会一直通过线程发送给follower消息;当某一个follower超过一定时间后没有收到消息,则向集群内发送成为主的请求,通过消息序号决定论次; 阅读全文
posted @ 2021-07-09 17:55 花花公子1234 阅读(50) 评论(0) 推荐(0)