summaryrefslogtreecommitdiffstats
path: root/src/include/util/lockfree/counter.H
blob: 1ff61fc77b27a1a23ab0b63ae31ee8176845cb9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
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
OpenPOWER on IntegriCloud