Permalink
Switch branches/tags
Nothing to show
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
38 lines (28 sloc) 473 Bytes
//
// Created by Fu Yong Quah on 11/18/15.
//
#ifndef FISHOTRON_ATOMIC_H
#define FISHOTRON_ATOMIC_H
#include <mutex>
namespace fishotron {
template<typename T>
class Atomic {
private:
std::mutex mtx;
T val;
public:
T load() {
T tmp;
mtx.lock();
tmp = val;
mtx.unlock();
return tmp;
}
void store(T arg) {
mtx.lock();
val = arg;
mtx.unlock();
}
};
}
#endif //FISHOTRON_ATOMIC_H