请声明出处:

NamedCounter,对象命名的计数器:

 

/**
 * An atomic counter with an associated name
 * 关联名的原子计数器
 * @short Atomic counter with name
 * @short 名字的原子计数器
 */
class YATE_API NamedCounter : public String
{
    YNOCOPY(NamedCounter); // no automatic copies please
public:
    /**
     * Constructor
     * 构造函数
     * @param name Name of the counter
     * @参数name,计数器的名字
     */
    explicit NamedCounter(const String& name);

    /**
     * Check if the counter is enabled
     * 检查计数器是否是启用的
     * @return True if the counter is enabled
     * @返回true,如果计数器是启动的
     */
    inline bool enabled() const
	{ return m_enabled; }

    /**
     * Enable or disable the counter
     * 启用或者禁用这个计数器
     * @param val True to enable counter, false to disable
     * @参数val,true , 启用,false, 禁止
     */
    inline void enable(bool val)
	{ m_enabled = val; }

    /**
     * Increment the counter
     * 增加计数
     * @return Post-increment value of the counter
     * @返回计数器增加之后的值
     */
    int inc();

    /**
     * Decrement the counter
     * 减少计数
     * @return Post-decrement value of the counter
     * @返回计数器减少之后的值
     */
    int dec();

    /**
     * Get the current value of the counter
     * 获得当前计数器的值
     * @return Value of the counter
     * @返回计数器的值
     */
    inline int count() const
	{ return m_count; }

private:
    int m_count;
    bool m_enabled;
    Mutex* m_mutex;
};