摘要: 一:设置一个函数指针,在需要使用的时候调用 #include <iostream> typedef void (__stdcall *DownloadCallback)(const char *pURL,bool OK); void DownLoadFile(const char *pURL,Dow 阅读全文
posted @ 2019-04-29 15:46 无解的不等式 阅读(375) 评论(0) 推荐(0) 编辑
摘要: 单例模式功能: 1. 确保一个类只有一个实例被建立 2. 提供了一个对对象的全局访问指针 3. 在不影响单例类的客户端的情况下允许将来有多个实例 一:懒汉式(特点:延迟加载,用的时候才创建对象) class CSingleton { public: static CSingleton* GetIns 阅读全文
posted @ 2019-04-28 17:48 无解的不等式 阅读(94) 评论(0) 推荐(0) 编辑
摘要: 1、基本概念同步:同步函数一般指调用函数后,等到函数功能实现再返回,期间一直霸占的CPU,等待期间同一个线程无法执行其他函数 异步:异步函数指调用函数后,不管函数功能是否实现,立马返回;通过回调函数等告知函数功能完成 阻塞:调用某些函数阻塞是因为函数功能没有实现,主动放弃CPU,让其他线程的得以执行 阅读全文
posted @ 2019-04-28 15:10 无解的不等式 阅读(236) 评论(0) 推荐(0) 编辑
摘要: 一:两个进程间的两个线程通信,相当于进程间通信 二:一个进程中的两个线程间通信 通信方式: 1.互斥锁 mutex; lock_guard (在构造函数里加锁,在析构函数里解锁) unique_lock 自动加锁、解锁 2.读写锁 shared_lock 3.信号量 c++11中未实现,可以自己使用 阅读全文
posted @ 2019-04-28 14:58 无解的不等式 阅读(17058) 评论(0) 推荐(1) 编辑
摘要: #include #include #include #include #include #include static const int kItemRepositorySize = 4; // Item buffer size. static const int kItemsToProduce = 10; // How many items we plan to pr... 阅读全文
posted @ 2019-04-25 16:15 无解的不等式 阅读(438) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include static const int kItemRepositorySize = 4; // Item buffer size. static const int kItemsToProduce = 10; // How many items we plan to pr... 阅读全文
posted @ 2019-04-25 16:14 无解的不等式 阅读(167) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include static const int kItemRepositorySize = 4; // Item buffer size. static const int kItemsToProduce = 10; // How many items we plan to pr... 阅读全文
posted @ 2019-04-25 16:13 无解的不等式 阅读(511) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include static const int kItemRepositorySize = 10; // Item buffer size. static const int kItemsToProduce = 1000; // How many items we plan to... 阅读全文
posted @ 2019-04-25 16:05 无解的不等式 阅读(171) 评论(0) 推荐(0) 编辑