00001 00023 #ifndef GALOIS_CHECKEDOBJECT_H 00024 #define GALOIS_CHECKEDOBJECT_H 00025 00026 #include "Galois/Runtime/Context.h" 00027 00028 namespace Galois { 00029 00035 template<typename T> 00036 class GChecked : public Galois::Runtime::Lockable { 00037 T val; 00038 00039 public: 00040 template<typename... Args> 00041 GChecked(Args&&... args): val(std::forward<Args>(args)...) { } 00042 00043 T& get(Galois::MethodFlag m = MethodFlag::ALL) { 00044 Galois::Runtime::acquire(this, m); 00045 return val; 00046 } 00047 00048 const T& get(Galois::MethodFlag m = MethodFlag::ALL) const { 00049 Galois::Runtime::acquire(const_cast<GChecked*>(this), m); 00050 return val; 00051 } 00052 }; 00053 00054 template<> 00055 class GChecked<void>: public Galois::Runtime::Lockable { 00056 public: 00057 void get(Galois::MethodFlag m = MethodFlag::ALL) const { 00058 Galois::Runtime::acquire(const_cast<GChecked*>(this), m); 00059 } 00060 }; 00061 00062 } 00063 00064 #endif // _GALOIS_CHECKEDOBJECT_H