📄 wyonce.h
字号:
/* Copyright is licensed under GNU LGPL. by I.J.Wang 2003*/#ifndef WYONCE_H__#define WYONCE_H__#define WYONCE_VERSION 31#include "wyret.h" // include libwy base definitions#include <pthread.h>/* WyOnce defines the object that ensures the only member function once(...) calls the given paramter function at most once.*/class WyOnce { public: // // [Syn] Construct default object // inline WyOnce() WY__TSPC() :_ovar(DefaultValue) {}; // // [Syn] Construct object and call the given parameter function immedicately. // // Note: If object is declared auto, static modifier may be required. // // [Throw] // explicit // no implicit conversion inline WyOnce( void(*once_func)(void) ) :_ovar(DefaultValue) { once(once_func); }; // // [Syn] Is object the same as that of default constructed state. // // [Ret] true = object is the same as default constructed state. // false= otherwise // bool is_default(void) const WY__TSPC() { return _ovar==DefaultValue; }; // // [Syn] Call the parameter function at most once. // This function moves object away from the default state // // [Throw] // void once( void(*once_func)(void) ); private: static const ::pthread_once_t DefaultValue=PTHREAD_ONCE_INIT; ::pthread_once_t _ovar; WyOnce(const WyOnce&) WY__TSPC(); // not to use const WyOnce& operator=(const WyOnce&) WY__TSPC(); // not to use bool operator==(const WyOnce&) WY__TSPC(); // not to use};#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -