Clang-format!!!
This commit is contained in:
parent
f190df8621
commit
96ba1079b2
122 changed files with 41245 additions and 39820 deletions
|
@ -25,49 +25,56 @@ namespace ZeroTier {
|
|||
/**
|
||||
* Simple atomic counter supporting increment and decrement
|
||||
*/
|
||||
class AtomicCounter
|
||||
{
|
||||
public:
|
||||
AtomicCounter() { _v = 0; }
|
||||
class AtomicCounter {
|
||||
public:
|
||||
AtomicCounter()
|
||||
{
|
||||
_v = 0;
|
||||
}
|
||||
|
||||
inline int load() const
|
||||
{
|
||||
inline int load() const
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return __sync_or_and_fetch(const_cast<int *>(&_v),0);
|
||||
return __sync_or_and_fetch(const_cast<int*>(&_v), 0);
|
||||
#else
|
||||
return _v.load();
|
||||
return _v.load();
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline int operator++()
|
||||
{
|
||||
inline int operator++()
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return __sync_add_and_fetch(&_v,1);
|
||||
return __sync_add_and_fetch(&_v, 1);
|
||||
#else
|
||||
return ++_v;
|
||||
return ++_v;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
inline int operator--()
|
||||
{
|
||||
inline int operator--()
|
||||
{
|
||||
#ifdef __GNUC__
|
||||
return __sync_sub_and_fetch(&_v,1);
|
||||
return __sync_sub_and_fetch(&_v, 1);
|
||||
#else
|
||||
return --_v;
|
||||
return --_v;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
AtomicCounter(const AtomicCounter &) {}
|
||||
const AtomicCounter &operator=(const AtomicCounter &) { return *this; }
|
||||
private:
|
||||
AtomicCounter(const AtomicCounter&)
|
||||
{
|
||||
}
|
||||
const AtomicCounter& operator=(const AtomicCounter&)
|
||||
{
|
||||
return *this;
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
int _v;
|
||||
int _v;
|
||||
#else
|
||||
std::atomic_int _v;
|
||||
std::atomic_int _v;
|
||||
#endif
|
||||
};
|
||||
|
||||
} // namespace ZeroTier
|
||||
} // namespace ZeroTier
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue