请声明出处:http://blog.csdn.net/u012377333/article/details/45499749
Lockable,互斥锁的基类:
/**
* An abstract base class for implementing lockable objects
* 可以实现锁定对象的抽象基类
* @short Abstract interface for lockable objects
* @short 可锁定的对象的抽象接口
*/
class YATE_API Lockable
{
public:
/**
* Destructor
* 析构函数
*/
virtual ~Lockable();
/**
* Attempt to lock the object and eventually wait for it
* 试图锁定对象,并最终等待它
* @param maxwait Time in microseconds to wait, -1 wait forever
* @参数maxwait,时间以微秒为单位等,-1永远等待
* @return True if successfully locked, false on failure
* @返回true,如果锁定成功,false,失败
*/
virtual bool lock(long maxwait = -1) = 0;
/**
* Unlock the object, does never wait
* 接触对象锁定,从不等待
* @return True if successfully unlocked the object
* @返回true, 如果成功解锁
*/
virtual bool unlock() = 0;
/**
* Check if the object is currently locked - as it's asynchronous it
* guarantees nothing if other thread changes the status
* 检查对象目前锁定——它的异步无法保证如果其他线程更改状态
* @return True if the object was locked when the function was called
* 返回true,如果对象被锁定,当函数被调用
*/
virtual bool locked() const = 0;
/**
* Check if the object is unlocked (try to lock and unlock it)
* 检查对象是否解锁(尝试加锁或者解锁)
* @param maxwait Time in microseconds to wait, -1 to wait forever
* @参数maxwait,时间以微秒为单位等,-1永远等待
* @return True if successfully locked and unlocked, false on failure
* @返回true,如果锁定和解锁成功,false,失败
*/
virtual bool check(long maxwait = -1);
/**
* Fully unlock the object, even if it was previously multiple locked.
* 完全释放的对象,即使是以前多个锁
* There is no guarantee about the object status after the function returns.
* 不能保证对象在函数返回后状态。
* This function should be used only if you understand it very well
* 这个函数仅仅应该在理解的的情况下使用
* @return True if the object was fully unlocked
* @返回true,如果对象被完全解锁
*/
virtual bool unlockAll();
/**
* Set a maximum wait time for debugging purposes
* 设置用于调试目的最大的等待时间
* @param maxwait Maximum time in microseconds to wait for any lockable
* object when no time limit was requested, zero to disable limit
* @参数maxwait, 最长时间以微秒为单位等任何可
* 锁定的对象没有时间限制要求时,0 禁用限制
*/
static void wait(unsigned long maxwait);
/**
* Get the maximum wait time used for debugging purposes
* 获得用于调试目的最大的等待时间
* @return Maximum time in microseconds, zero if no maximum is set
* @返回微秒最大时间,zero,如果没有设置
*/
static unsigned long wait();
/**
* Start actually using lockables, for platforms where these objects are not
* usable in global object constructors.
* 开始实际使用可封闭的平台,这些对象是没有
* 可用的全局对象构造函数。
* This method must be called at least once somewhere from main() but
* before creating any threads and without holding any object locked.
* 调用这个方法必须至少一次在从主()但在创建
* 任何线程和锁不持有任何对象。
*/
static void startUsingNow();
/**
* Enable some safety and sanity check features.
* 使一些安全性和完整性检查功能
* This provides a safer code and easier locking debugging at the price of performance penalty.
* 这提供了一种更安全的代码和更容易锁定调试性能损失为代价的。
* This method must be called early and not changed after initialization
* 早期必须调用此方法,初始化后没有改变
* @param safe True to enable locking safety measures, false to disable
* @参数safe,true 启用锁定安全措施,false 禁用
*/
static void enableSafety(bool safe = true);
};