当前位置: 首页 > news >正文

云存储能用来做网站吗网页制作费用大概多少

云存储能用来做网站吗,网页制作费用大概多少,网站建设小结报告,额敏网站建设简介 asio设计static_mutex为了处理静态互斥量,即全局静态互斥量,其针对不同平台有不同的实现 静态互斥量static_mutex 通过条件编译对不同实现定义别名 #if !defined(BOOST_ASIO_HAS_THREADS) typedef null_static_mutex static_mutex; # define BO…

简介

asio设计static_mutex为了处理静态互斥量,即全局静态互斥量,其针对不同平台有不同的实现

静态互斥量static_mutex

通过条件编译对不同实现定义别名

#if !defined(BOOST_ASIO_HAS_THREADS)
typedef null_static_mutex static_mutex;
# define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_NULL_STATIC_MUTEX_INIT
#elif defined(BOOST_ASIO_WINDOWS)
typedef win_static_mutex static_mutex;
# define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_WIN_STATIC_MUTEX_INIT
#elif defined(BOOST_ASIO_HAS_PTHREADS)
typedef posix_static_mutex static_mutex;
# define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_POSIX_STATIC_MUTEX_INIT
#elif defined(BOOST_ASIO_HAS_STD_MUTEX_AND_CONDVAR)
typedef std_static_mutex static_mutex;
# define BOOST_ASIO_STATIC_MUTEX_INIT BOOST_ASIO_STD_STATIC_MUTEX_INIT
#endif

主要包含三个方法

  • init
  • lock
  • unlock

实现

windows平台实现

window平台为win_static_mutex,其定义为

struct win_static_mutex
{typedef boost::asio::detail::scoped_lock<win_static_mutex> scoped_lock;// Initialise the mutex.BOOST_ASIO_DECL void init();// Initialisation must be performed in a separate function to the "public"// init() function since the compiler does not support the use of structured// exceptions and C++ exceptions in the same function.BOOST_ASIO_DECL int do_init();// Lock the mutex.void lock(){::EnterCriticalSection(&crit_section_);}// Unlock the mutex.void unlock(){::LeaveCriticalSection(&crit_section_);}bool initialised_;::CRITICAL_SECTION crit_section_;
};

其初始化是通过创建有名互斥量,来保证只初始化一次

HANDLE mutex = ::CreateMutexW(0, TRUE, mutex_name);
//说明另一个线程已经创建互斥量,等待另一线程初始化完释放互斥量。因为创建成功的线程持有
if (last_error == ERROR_ALREADY_EXISTS)   ::WaitForSingleObject(mutex, INFINITE);
//初始化临界区
#if defined(__MINGW32__)// Not sure if MinGW supports structured exception handling, so for now// we'll just call the Windows API and hope.
# if defined(UNDER_CE)::InitializeCriticalSection(&crit_section_);
# elseif (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)){last_error = ::GetLastError();::ReleaseMutex(mutex);::CloseHandle(mutex);return last_error;}
# endif
#else__try{
# if defined(UNDER_CE)::InitializeCriticalSection(&crit_section_);
# elseif (!::InitializeCriticalSectionAndSpinCount(&crit_section_, 0x80000000)){last_error = ::GetLastError();::ReleaseMutex(mutex);::CloseHandle(mutex);return last_error;}
# endif}__except(GetExceptionCode() == STATUS_NO_MEMORY? EXCEPTION_EXECUTE_HANDLER : EXCEPTION_CONTINUE_SEARCH){::ReleaseMutex(mutex);::CloseHandle(mutex);return ERROR_OUTOFMEMORY;}
#endifinitialised_ = true;::ReleaseMutex(mutex);::CloseHandle(mutex);

同时在类中定义有scoped_lock,用于互斥量的RAII
其静态初始化为

#if defined(UNDER_CE)
# define BOOST_ASIO_WIN_STATIC_MUTEX_INIT { false, { 0, 0, 0, 0, 0 } }
#else // defined(UNDER_CE)
# define BOOST_ASIO_WIN_STATIC_MUTEX_INIT { false, { 0, 0, 0, 0, 0, 0 } }
#endif // defined(UNDER_CE)

linux平台实现

实现是posix_static_mutex,其定义为

struct posix_static_mutex
{typedef boost::asio::detail::scoped_lock<posix_static_mutex> scoped_lock;// Initialise the mutex.void init(){// Nothing to do.}// Lock the mutex.void lock(){(void)::pthread_mutex_lock(&mutex_); // Ignore EINVAL.}// Unlock the mutex.void unlock(){(void)::pthread_mutex_unlock(&mutex_); // Ignore EINVAL.}::pthread_mutex_t mutex_;
};
//初始化
#define BOOST_ASIO_POSIX_STATIC_MUTEX_INIT { PTHREAD_MUTEX_INITIALIZER }

std标准实现

实现类为std_static_mutex,定义为

class std_static_mutex: private noncopyable
{
public:typedef boost::asio::detail::scoped_lock<std_static_mutex> scoped_lock;// Constructor.std_static_mutex(int){}// Destructor.~std_static_mutex(){}// Initialise the mutex.void init(){// Nothing to do.}// Lock the mutex.void lock(){mutex_.lock();}// Unlock the mutex.void unlock(){mutex_.unlock();}private:friend class std_event;std::mutex mutex_;
};//初始化
#define BOOST_ASIO_STD_STATIC_MUTEX_INIT 0

空实现

实现类为null_static_mutex,定义为

struct null_static_mutex
{typedef boost::asio::detail::scoped_lock<null_static_mutex> scoped_lock;// Initialise the mutex.void init(){}// Lock the mutex.void lock(){}// Unlock the mutex.void unlock(){}int unused_;
};
//初始化
#define BOOST_ASIO_NULL_STATIC_MUTEX_INIT { 0 }
http://www.dtcms.com/a/521450.html

相关文章:

  • 2017辽宁建设厅查询网站大连网站建设公司排名
  • 性能测试-jmeter16-性能环境搭建、脚本编写、测试数据构造
  • 网站建设分为哪几种类型平台类网站建设价格表
  • kubernets简介和部署
  • YOLO V4 整体架构的由来及用法 详解
  • 青岛网站开发公司wordpress js加载速度慢
  • 上海松一网站建设wordpress产品展示
  • python-xml
  • 番禺网站建设专家wordpress set option
  • 郑州模板网站设计哪家便宜推广策略及推广方式
  • RTMP推拉流平台EasyDSS视频推拉流技术的应用以及视频推流是怎样的流程?
  • JDBC-MySQL数据库连接与使用
  • 江门cms模板建站寮步镇网站建设
  • 网站后台用什么软件做iphone app wordpress
  • 网站登录密码怎么取消保存dremrever怎么做网站
  • 集团门户网站建设策划关于加快信用平台网站建设通知
  • SpringBoot-Web开发之请求映射
  • Java 核心知识点查漏补缺(三)
  • Linux 线程深度解析:概念、机制与实践
  • 网站运营总监盐城最专业网站建设网站排名优化
  • KP1505X (KP15052SPA/KP15051SPA/ KP1505ASPA) 典型应用 与管脚封装
  • 【数据集1】Global precipitation from FY-3 polar orbit satellites
  • h5游戏免费下载:我要飞的更高
  • 网站开发设计价格爱家影院融合年包是什么
  • 中国网站为什么要备案网站域名备案服务
  • TCP实现聊天
  • 网站设计合同附件wordpress 克隆页面
  • 富文本测试
  • 韩国的小游戏网站网站建设企业排行榜
  • CSRF漏洞攻击(跨站请求伪造攻击)