![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
cpp杂七杂八
xd96dx
这个作者很懒,什么都没留下…
展开
-
c++ 无锁线程安全stack
最近看了本多线程的书, 记录下笔记#include <atomic>#include <memory>#include <thread>#include <future>#include <vector>#include <chrono>namespace lock_stack { template<typename T> class lock_free_stack { private原创 2022-01-22 16:16:17 · 554 阅读 · 0 评论 -
c++ 互斥量的常见问题(未保护共享数据)
namespace mutex_invalid { void func_asign(void(*func)(int&), int& data) { std::cout << "in func: " << data << std::endl; func(data); // data 传入的本意可能只是在线程中使用, 而不是修改 } void func_asign_test(int& num原创 2021-09-17 22:59:35 · 125 阅读 · 0 评论 -
c++ 文件对比
#include <iostream>#include <fstream>#include <cstring>#include <cstdio>/*pos, file1 偏移量pos1, file2 偏移量end, 对比的字符个数*/bool compare_file(const std::string &f1, const std::string &f2, size_t pos=0, size_t pos1=原创 2021-06-10 17:58:01 · 759 阅读 · 0 评论