- 博客(526)
- 资源 (14)
- 收藏
- 关注

原创 使用内存映射替换文件内容
template <class T>class single_instance {public: static inline T instance() { static T obj; return obj; }private: single_instance() = default; virtual ~single_instance() = default;};#include <string.h>#i.
2020-05-11 19:02:28
195
1

原创 libcap应用:按协议抓取网络包
#include <stdio.h>#include <stdlib.h>#include <time.h>#include <sys/time.h>#include <stdint.h>#include <string.h>#include <sys/socket.h>#include <n...
2020-03-22 15:33:41
324

原创 zlib压缩解压缩字符串为gzip格式
#include <stdio.h>#include <string.h>#include <iostream>#include <string>#include <fstream>#include <zlib.h>static bool gzip_compress(const std::string &...
2020-01-20 11:25:20
544
2

原创 rest_rpc应用-从服务器下载文件到本地
1.rest_rpc:https://github.com/qicosmos/rest_rpc2.服务端:server.cpp#include <iostream>#include <string>#include <fstream>#include <thread>#include "rpc_server.h"using n...
2020-01-19 15:08:16
427
1

原创 boost:any构建可变参数函数分发器
#include <iostream>#include <string>#include <algorithm>#include <unordered_map>#include <memory>#include <functional>#include <stdexcept>#include <...
2019-12-11 19:25:55
222

原创 boost asio组播
1.sender#include <iostream>#include <string>#include <sstream>#include <chrono>#include <boost/asio.hpp>class sender {public: sender(boost::asio::io_service ...
2019-12-10 11:19:05
1252
2

原创 crtp应用-- 具备多种行为类
#include <iostream>template <typename Derive>struct swim { swim(const Derive &d) : self(d) { } void to_swim() { std::cout << self.name << " can swim...
2019-12-09 14:15:31
150

原创 leetcode移除元素
class Solution {public: int removeElement(vector<int>& nums, int val) { int size = nums.size(); if (size <= 0) { return 0; } int start = ...
2019-12-09 10:03:32
38

原创 zmq发布订阅模式原型--支持断链重连 可扩展于多个业务场景 比如服务器发布配置信息等
1.zmq_ageng.hpp#ifndef SRC_ZMQ_AGENT_HPP_#define SRC_ZMQ_AGENT_HPP_#include <string.h>#include <string>#include <map>#include <zmq.h>namespace zmq_self_agent {enum so...
2019-12-03 16:18:27
687
3

原创 epoll tcp server 演示收发消息
#include <stdlib.h>#include <unistd.h>#include <stdlib.h>#include <string.h>#include <fcntl.h>#include <sys/epoll.h>#include <sys/socket.h>#include &l...
2019-10-31 17:55:33
245

原创 trie_tree c++封装
#include <stdlib.h>#include <time.h>#include <iostream>#include <vector>#include <string>#include <thread>#define SAFE_DEL(p) do { if (nullptr != p) { delete...
2019-10-26 17:11:29
112

原创 统计网络流量
#include <unistd.h>#include <string.h>#include <sys/types.h>#include <sys/stat.h>#include <ctype.h>#include <fcntl.h>#include <iostream>#include <s...
2019-10-21 17:46:01
195

原创 跳表程序
#include <string.h>#include <time.h>#include <iostream>#include <map>#include <stdexcept>template <typename KeyType, typename ValueType>struct skip_list_node...
2019-10-19 17:58:03
87

原创 元编程应用-判读容器类型
#include <iostream>#include <string>#include <vector>#include <map>#include <unordered_map>#include <list>#include <queue>#include <deque>#incl...
2019-09-16 21:04:14
82

原创 google benchmark应用
#include <string.h>#include <iostream>#include <set>#include <string>#include <benchmark/benchmark.h>#define SAFE_DEL(ptr) { if (ptr) delete ptr; ptr = nullptr; }t...
2019-09-07 15:15:31
327

原创 线程安全ring buffer
#include <iostream>#include <string>#include <vector>#include <atomic>struct SpinLock { SpinLock(std::atomic_flag &flag) : flag_(flag) { while (true == fla...
2019-09-04 11:20:48
424

原创 一种存储表结构方法
#include <stdlib.h>#include <assert.h>#include <iostream>#include <string>#include <unordered_map>#include <memory>static const std::string S_EMPTY_STRING;#...
2019-08-23 14:15:01
176

原创 lock free queue
#include <iostream>#include <string>#include <vector>#include <atomic>#include <chrono>#include <thread>#include <type_traits>#include <stdexcept&g...
2019-08-11 22:00:43
360

原创 异步asio udp server和client (单线程)
1.asyn_asio_udp_server.hpp#ifndef ASYN_ASIO_UDP_SERVER_HPP_#define ASYN_ASIO_UDP_SERVER_HPP_#include <string.h>#include <iostream>#include <string>#include "boost/asio.hpp"...
2019-07-07 14:06:50
902
1

原创 测试系统堆内存
一 需求:使用new操作测试程序最多可申请多大的堆内存二 实现:1.直接使用new直接使用new可能会抛出bad_alloc异常,所以要使用try catch捕获2.使用new(nothrow)分配失败不会抛出异常,而是返回空指针三 代码:1.test.cpp#include <stdint.h>#include <iostream>...
2019-07-04 15:43:33
190

原创 redis client pool
1.redis_client.hpp#ifndef REDIS_CLIENT_HPP_#define REDIS_CLIENT_HPP_#include <hiredis/hiredis.h>#include <string.h>#include <iostream>#include <string>using namespace ...
2019-07-03 21:01:53
508

原创 程序性能优化---倒置字符串中单词
需求:输入 have a nice day输出 day nice a have实现:#include <unistd.h>#include <iostream>#include <vector>#include <sstream>#include <stack>using namespace std;stri...
2019-07-03 16:30:23
148

原创 使用select实现异步定时器
需求:实现异步定时器,不干扰其它线程实现:使用select作为超时API,但一定程度增加系统payload代码:select_timer.hpp#ifndef SRC_SELECT_TIMER_HPP_#define SRC_SELECT_TIMER_HPP_#include <sys/time.h>#include <iostream>#...
2019-07-01 18:55:52
1144

原创 使用消息注册机制实现消息通信机制
一 需求:将消息通信进行抽象,支持udp,tcp,zmq等方式二 实现:1.消息通信实体#ifndef SRC_MESSAGE_COMMUNICATE_ENTITY_HPP_#define SRC_MESSAGE_COMMUNICATE_ENTITY_HPP_#include <stdio.h>#include <stdlib.h>#include...
2019-06-20 13:45:17
412

原创 易用的zmq rounter/dealer模式
一 rounter/dealerclient <=> server (rounter<=>dealer) <=> work0, work1,...二 需求:client发送指令到server,server立刻回收到响应,server异步处理指令,周期性给client回复处理结果。三 解决思路:server采用rounter/dealer模式,...
2019-06-19 13:15:22
630
原创 android adb install安装APK报“INSTALL_FAILED_VERSION_DOWNGRADE”
android adb install安装APK报“INSTALL_FAILED_VERSION_DOWNGRADE”
2023-03-25 14:53:01
2
原创 Android 从一个Activity跳转到另一个APP的Activity
APP开发时需要点击某个按钮,退出本身Activity后跳转到系统中另一个APP的Activity
2023-02-08 09:31:02
169
原创 android studio升级后导致Android工程无法编译问题的解决方法
android studio升级后导致Android工程无法编译问题的解决方法
2023-02-06 19:38:28
213
原创 android studio编译报“ndk\23.1.7779620 did not have a source.properties file”错误
android studio编译报“ndk\23.1.7779620 did not have a source.properties file”错误
2023-01-13 09:21:34
293
原创 android camera2业务代码引入uyvy格式转换引起“ maxImages (1) has already been acquired, call ...“异常
在android camera2基础上取到img的Y,U,V三个通道数据后,生成uyvy格式并转为nv12后发生崩溃现象,打开logcat日志,发现有如下异常信息:2022-12-15 17:14:54.881 9593-9628/com.arcsoft.se1000dmstestbed E/AndroidRuntime: FATAL EXCEPTION: BasicCamera2Thread Process: com.arcsoft.se1000dmstestbed, PID: 9593
2023-01-07 17:51:59
151
原创 android GLSurfaceView出现“Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 1863”
android GLSurfaceView出现“Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x0 in tid 1863”
2022-12-21 15:31:58
188
多边形游戏
2012-01-22
字符串匹配程序
2012-01-21
计算机集群
2012-01-19
大规模并行处理机系统 MPP
2012-01-18
对称多处理机
2012-01-18
Interconnection Network
2012-01-18
Communication in Multiprocessor Systems
2012-01-18
高级计算机测试
2012-01-18
高级体系结构课程纲要
2012-01-18
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人