1. 程式人生 > >boost庫 學習筆記一 boost::share_mutex 互斥鎖 讀寫鎖

boost庫 學習筆記一 boost::share_mutex 互斥鎖 讀寫鎖

#include <boost/thread/mutex>

typedef boost::shared_mutex  rwMutex;



typedef boost::shared_lock<rwMutex>  ReadLocker;
typedef boost::unique_lock<rwMutex>  WriteLocker;   //讀寫鎖


typedef boost::unique_lock<rwMutex>  exclusiveLock;  //互斥鎖

boost::share_ptr   引用計數型智慧指標

boost::share_ptr<int>   m_str(new int(5));

boost::share_ptr<char> p_chr(new char[MAX_PATH]);

memset(p_chr.get(), 0, MAX_PATH);

strcpy(p_chr.get(), "strung");