aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib/utils
diff options
context:
space:
mode:
authorJack Lloyd <[email protected]>2017-09-30 12:17:39 -0400
committerJack Lloyd <[email protected]>2017-09-30 12:17:39 -0400
commit62eb9857a46ddc508798176e3f77830ff0034e1b (patch)
tree43388f1a63236f82de13d9d308ac8fda79d201c5 /src/lib/utils
parentf6dc3db8bb7e31569ed1a6042771e3f529aefab8 (diff)
Address some MSVC warnings
Diffstat (limited to 'src/lib/utils')
-rw-r--r--src/lib/utils/barrier.cpp4
-rw-r--r--src/lib/utils/barrier.h40
2 files changed, 24 insertions, 20 deletions
diff --git a/src/lib/utils/barrier.cpp b/src/lib/utils/barrier.cpp
index 81c578b72..3c721d905 100644
--- a/src/lib/utils/barrier.cpp
+++ b/src/lib/utils/barrier.cpp
@@ -11,7 +11,7 @@
namespace Botan {
-void Barrier::wait(unsigned delta)
+void Barrier::wait(size_t delta)
{
lock_guard_type<mutex_type> lock(m_mutex);
m_value += delta;
@@ -23,7 +23,7 @@ void Barrier::sync()
--m_value;
if(m_value > 0)
{
- unsigned current_syncs = m_syncs;
+ const size_t current_syncs = m_syncs;
m_cond.wait(lock, [this, &current_syncs] { return m_syncs != current_syncs; });
}
else
diff --git a/src/lib/utils/barrier.h b/src/lib/utils/barrier.h
index 9b7fdd59d..943d10b0c 100644
--- a/src/lib/utils/barrier.h
+++ b/src/lib/utils/barrier.h
@@ -11,33 +11,37 @@
#include <botan/mutex.h>
#if defined(BOTAN_TARGET_OS_HAS_THREADS)
-#include <condition_variable>
+ #include <condition_variable>
#endif
namespace Botan {
#if defined(BOTAN_TARGET_OS_HAS_THREADS)
-// Barrier implements a barrier synchronization primitive. wait() will indicate
-// how many threads to synchronize; each thread needing synchronization should
-// call sync(). When sync() returns, the barrier is reset to zero, and the
-// m_syncs counter is incremented. m_syncs is a counter to ensure that wait()
-// can be called after a sync() even if the previously sleeping threads have
-// not awoken.)
+
+/**
+Barrier implements a barrier synchronization primitive. wait() will
+indicate how many threads to synchronize; each thread needing
+synchronization should call sync(). When sync() returns, the barrier
+is reset to zero, and the m_syncs counter is incremented. m_syncs is a
+counter to ensure that wait() can be called after a sync() even if the
+previously sleeping threads have not awoken.)
+*/
class Barrier final
- {
- public:
- explicit Barrier(int value = 0) : m_value(value), m_syncs(0) {}
+ {
+ public:
+ explicit Barrier(int value = 0) : m_value(value), m_syncs(0) {}
+
+ void wait(size_t delta);
- void wait(unsigned delta);
+ void sync();
- void sync();
+ private:
+ int m_value;
+ size_t m_syncs;
+ mutex_type m_mutex;
+ std::condition_variable m_cond;
+ };
- private:
- int m_value;
- unsigned m_syncs;
- mutex_type m_mutex;
- std::condition_variable m_cond;
- };
#endif
}