
muduo多线程编程
yvhqbat
whuster
展开
-
muduo中用到的boost库
参考boost文档: http://www.boost.org/doc/libs/1_61_0/1. boost::bindhttp://www.boost.org/doc/libs/1_61_0/libs/bind/doc/html/bind.html Purpose: boost::bind is a generalization of the standard functions std原创 2016-06-17 16:02:01 · 1543 阅读 · 0 评论 -
muduo:互斥量
1. MutexLock类// Use as data member of a class, eg.//// class Foo// {// public:// int size() const;//// private:// mutable MutexLock mutex_;// std::vector<int> data_; // GUARDED BY mute原创 2016-06-17 17:16:52 · 286 阅读 · 0 评论 -
muduo:线程池
这里写代码片原创 2016-06-20 21:18:26 · 399 阅读 · 0 评论 -
muduo:Singleton类,单例模式
#include <boost/noncopyable.hpp>#include <assert.h>#include <stdlib.h> // atexit#include <pthread.h>template<typename T>class Singleton : boost::noncopyable{ public: static T& instance() {原创 2016-06-20 23:06:14 · 1141 阅读 · 0 评论 -
linux多线程编程中用到的函数和类型
1. pthread_fork()#include <pthread.h>int pthread_atfork(void (*prepare)(void), void (*parent)(void), void (*child)(void)); /*Description:The pthread_atfork() function shall declare fork handlers to原创 2016-06-17 15:46:43 · 494 阅读 · 0 评论 -
线程特定数据(TSD)
单线程中,用“全局变量”以实现多个函数间共享数据。多线程环境下,由于数据空间是共享的,因此全局变量也为所有线程所共有。但有时需要 线程私有的全局变量,仅在某个线程中有效,但却可以跨多个函数访问。POSIX线程库 通过维护一定的数据结构来解决这个问题,这些数据称为Thread-specific Data. 也称线程本地存储Thread-Local-Storage对于POD类型的线程本地存储,原创 2016-06-21 09:38:54 · 1076 阅读 · 0 评论 -
muduo日志类的封装
1. 日志的作用错误分为: 1. 编译错误 2. 运行时错误(逻辑错误,使用GDB调试的话,很难分析。如果使用日志,将运行过程通过日志打印出来)作用: 1. 开发过程中: 调试错误 更好的理解程序:在阅读别人的代码是,通过添加日志,可以理清程序的整个流程。 2. 运行过程中: 诊断系统故障并处理 记录系统运行状态2. 日志 涉及到4个文件:logging.h lo原创 2016-06-21 22:56:40 · 451 阅读 · 0 评论