diff options
author | Patrick Williams <iawillia@us.ibm.com> | 2010-06-09 13:54:08 -0500 |
---|---|---|
committer | Patrick Williams <iawillia@us.ibm.com> | 2010-06-09 13:54:08 -0500 |
commit | cbbd9e5b225e743ee3b4688ac6a3b69a9876926a (patch) | |
tree | ac9ccc37c35855edeeecbf3ebe1cb55d3c2f6f89 /src/include/util | |
parent | 9a4698af6ee4c095a97b8800d2d5f0a4bb282b15 (diff) | |
download | talos-hostboot-cbbd9e5b225e743ee3b4688ac6a3b69a9876926a.tar.gz talos-hostboot-cbbd9e5b225e743ee3b4688ac6a3b69a9876926a.zip |
Refactor task-manager tid counter to generic lockfree algorithm.
Diffstat (limited to 'src/include/util')
-rw-r--r-- | src/include/util/lockfree/counter.H | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/include/util/lockfree/counter.H b/src/include/util/lockfree/counter.H new file mode 100644 index 000000000..1ff61fc77 --- /dev/null +++ b/src/include/util/lockfree/counter.H @@ -0,0 +1,23 @@ +#ifndef __UTIL_LOCKFREE_COUNTER_H +#define __UTIL_LOCKFREE_COUNTER_H + +namespace Util +{ + namespace Lockfree + { + template <typename _T> + class Counter + { + public: + Counter() : value(_T()) {}; + + _T next() { return __sync_fetch_and_add(&value, 1); }; + + private: + _T value; + }; + }; +}; + + +#endif |