Shinya Kitaoka 810553
#pragma once
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#ifndef TATOMICVAR_H
Toshihiro Shimizu 890ddd
#define TATOMICVAR_H
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#undef DVAPI
Toshihiro Shimizu 890ddd
#undef DVVAR
Toshihiro Shimizu 890ddd
#ifdef TNZCORE_EXPORTS
Toshihiro Shimizu 890ddd
#define DVAPI DV_EXPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_EXPORT_VAR
Toshihiro Shimizu 890ddd
#else
Toshihiro Shimizu 890ddd
#define DVAPI DV_IMPORT_API
Toshihiro Shimizu 890ddd
#define DVVAR DV_IMPORT_VAR
Toshihiro Shimizu 890ddd
#endif
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#include <atomic></atomic>
Toshihiro Shimizu 890ddd
Shinya Kitaoka 120a6e
class DVAPI TAtomicVar {
Toshihiro Shimizu 890ddd
public:
Shinya Kitaoka 652c93
  using value_type = long;
Shinya Kitaoka 652c93
Shinya Kitaoka 652c93
public:
Shinya Kitaoka 120a6e
  TAtomicVar() : m_var(0) {}
Toshihiro Shimizu 890ddd
Shinya Kitaoka 652c93
public:
Shinya Kitaoka 652c93
  value_type operator++() { return ++m_var; }
Shinya Kitaoka 652c93
  value_type operator--() { return --m_var; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 652c93
  value_type operator+=(value_type value) { return m_var += value; }
Toshihiro Shimizu 890ddd
Shinya Kitaoka 652c93
  bool operator<=(value_type rhs) { return m_var <= rhs; };
Toshihiro Shimizu 890ddd
Shinya Kitaoka 652c93
  operator value_type() const { return m_var; };
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#if !defined(LINUX) || defined(LINUX) && (__GNUC__ == 3) && (__GNUC_MINOR__ > 1)
Shinya Kitaoka 120a6e
private:  // to avoid well known bug in gcc3 ... fixed in later versions..
Toshihiro Shimizu 890ddd
#endif
Shinya Kitaoka 652c93
  TAtomicVar &operator=(const TAtomicVar &) = delete;  // not implemented
Shinya Kitaoka 652c93
  TAtomicVar(const TAtomicVar &v)           = delete;  // not implemented
Shinya Kitaoka 652c93
Shinya Kitaoka 652c93
private:
Shinya Kitaoka 652c93
  std::atomic<value_type> m_var;</value_type>
Toshihiro Shimizu 890ddd
};
Toshihiro Shimizu 890ddd
Toshihiro Shimizu 890ddd
#endif