mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
353 B
19 lines
353 B
9 years ago
|
#ifndef SRC_ATOMIC_POLYFILL_H_
|
||
|
#define SRC_ATOMIC_POLYFILL_H_
|
||
|
|
||
|
#include "util.h"
|
||
|
|
||
|
namespace nonstd {
|
||
|
|
||
|
template <typename T>
|
||
|
struct atomic {
|
||
|
atomic() = default;
|
||
|
T exchange(T value) { return __sync_lock_test_and_set(&value_, value); }
|
||
|
T value_ = T();
|
||
|
DISALLOW_COPY_AND_ASSIGN(atomic);
|
||
|
};
|
||
|
|
||
|
} // namespace nonstd
|
||
|
|
||
|
#endif // SRC_ATOMIC_POLYFILL_H_
|