diff options
author | Antonio Juarez <antonio.maria.juarez@live.com> | 2014-03-03 22:07:58 +0000 |
---|---|---|
committer | Antonio Juarez <antonio.maria.juarez@live.com> | 2014-03-03 22:07:58 +0000 |
commit | 296ae46ed8f8f6e5f986f978febad302e3df231a (patch) | |
tree | 1629164454a239308f33c9e12afb22e7f3cd8eeb /tests/unit_tests/unit_tests_utils.h | |
parent | changed name (diff) | |
download | monero-296ae46ed8f8f6e5f986f978febad302e3df231a.tar.xz |
moved all stuff to github
Diffstat (limited to '')
-rw-r--r-- | tests/unit_tests/unit_tests_utils.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/unit_tests/unit_tests_utils.h b/tests/unit_tests/unit_tests_utils.h new file mode 100644 index 000000000..9eebb7ed9 --- /dev/null +++ b/tests/unit_tests/unit_tests_utils.h @@ -0,0 +1,38 @@ +// Copyright (c) 2012-2013 The Cryptonote developers +// Distributed under the MIT/X11 software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#pragma once + +#include <atomic> + +namespace unit_test +{ + class call_counter + { + public: + call_counter() + : m_counter(0) + { + } + + void inc() volatile + { + // memory_order_relaxed is enough for call counter + m_counter.fetch_add(1, std::memory_order_relaxed); + } + + size_t get() volatile const + { + return m_counter.load(std::memory_order_relaxed); + } + + void reset() volatile + { + m_counter.store(0, std::memory_order_relaxed); + } + + private: + std::atomic<size_t> m_counter; + }; +} |