diff options
| author | Brian Anderson <banderson@mozilla.com> | 2012-03-05 13:32:40 -0800 |
|---|---|---|
| committer | Brian Anderson <banderson@mozilla.com> | 2012-03-05 19:39:56 -0800 |
| commit | 958c32108313658740e89dfd32c5a96ba557c0a3 (patch) | |
| tree | 543f436905d84a064cdd9fdd6259b9f7240c3f3a /src/rt/sync | |
| parent | 1347d04bb086f6d76dd7287762d34ef4c57dbc00 (diff) | |
rt: Fix the atomic get_ref_count method to avoid races
Diffstat (limited to 'src/rt/sync')
| -rw-r--r-- | src/rt/sync/sync.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/rt/sync/sync.h b/src/rt/sync/sync.h index e7d7496a56a..66682f11e9c 100644 --- a/src/rt/sync/sync.h +++ b/src/rt/sync/sync.h @@ -29,6 +29,16 @@ public: static T decrement(T &address) { return __sync_sub_and_fetch(&address, 1); } + + template <class T> + static T read(T *address) { + return __sync_add_and_fetch(address, 0); + } + + template <class T> + static T read(T &address) { + return __sync_add_and_fetch(&address, 0); + } }; #endif /* SYNC_H */ |
