#pragma once

#ifndef ATOMIC_PRIMITIVES_54BCFBD7_969C_468c_A8A5_164AF26DA379
#define ATOMIC_PRIMITIVES_54BCFBD7_969C_468c_A8A5_164AF26DA379

#include <stddef.h>

namespace NWebmaster {
namespace threads {

class counter {
public:
    typedef size_t value_type;

    counter();
    explicit counter(const value_type &rhs);
    explicit counter(const counter &rhs);

    const counter &operator+=(const value_type &rhs);
    const counter &operator-=(const value_type &rhs);
    const counter &operator++();
    const counter &operator--();

    operator value_type() const;
    value_type get() const;

private:
    volatile value_type val;
};

} //threads
} //namespace NWebmaster

#endif //ATOMIC_PRIMITIVES_54BCFBD7_969C_468c_A8A5_164AF26DA379
