use std::atomic instead of boost::atomic (#678)
use std::atomic instead of boost::atomic
This commit is contained in:
parent
a3de04dffc
commit
770afadcda
|
@ -46,7 +46,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
#include <boost/config.hpp>
|
#include <boost/config.hpp>
|
||||||
#include <boost/asio/detail/config.hpp>
|
#include <boost/asio/detail/config.hpp>
|
||||||
#include <boost/version.hpp>
|
#include <boost/version.hpp>
|
||||||
|
@ -152,7 +151,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#if defined __AMIGA__ || defined __amigaos__ || defined __AROS__
|
#if defined __AMIGA__ || defined __amigaos__ || defined __AROS__
|
||||||
#define TORRENT_AMIGA
|
#define TORRENT_AMIGA
|
||||||
#define TORRENT_USE_IPV6 0
|
#define TORRENT_USE_IPV6 0
|
||||||
#define TORRENT_USE_BOOST_THREAD 0
|
|
||||||
#define TORRENT_USE_IOSTREAM 0
|
#define TORRENT_USE_IOSTREAM 0
|
||||||
// set this to 1 to disable all floating point operations
|
// set this to 1 to disable all floating point operations
|
||||||
// (disables some float-dependent APIs)
|
// (disables some float-dependent APIs)
|
||||||
|
@ -171,7 +169,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
// the locale is always utf-8
|
// the locale is always utf-8
|
||||||
#if defined __APPLE__
|
#if defined __APPLE__
|
||||||
|
|
||||||
# define TORRENT_USE_OSATOMIC 1
|
|
||||||
# ifndef TORRENT_USE_ICONV
|
# ifndef TORRENT_USE_ICONV
|
||||||
# define TORRENT_USE_ICONV 0
|
# define TORRENT_USE_ICONV 0
|
||||||
# define TORRENT_USE_LOCALE 0
|
# define TORRENT_USE_LOCALE 0
|
||||||
|
@ -266,7 +263,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_USE_GETADAPTERSADDRESSES 1
|
#define TORRENT_USE_GETADAPTERSADDRESSES 1
|
||||||
#define TORRENT_HAS_SALEN 0
|
#define TORRENT_HAS_SALEN 0
|
||||||
#define TORRENT_USE_GETIPFORWARDTABLE 1
|
#define TORRENT_USE_GETIPFORWARDTABLE 1
|
||||||
#define TORRENT_USE_INTERLOCKED_ATOMIC 1
|
|
||||||
#ifndef TORRENT_USE_UNC_PATHS
|
#ifndef TORRENT_USE_UNC_PATHS
|
||||||
# define TORRENT_USE_UNC_PATHS 1
|
# define TORRENT_USE_UNC_PATHS 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -289,7 +285,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#endif
|
#endif
|
||||||
#define TORRENT_USE_RLIMIT 0
|
#define TORRENT_USE_RLIMIT 0
|
||||||
#define TORRENT_HAS_FALLOCATE 0
|
#define TORRENT_HAS_FALLOCATE 0
|
||||||
#define TORRENT_USE_INTERLOCKED_ATOMIC 1
|
|
||||||
#ifndef TORRENT_USE_UNC_PATHS
|
#ifndef TORRENT_USE_UNC_PATHS
|
||||||
# define TORRENT_USE_UNC_PATHS 1
|
# define TORRENT_USE_UNC_PATHS 1
|
||||||
#endif
|
#endif
|
||||||
|
@ -313,14 +308,12 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_HAS_SALEN 0
|
#define TORRENT_HAS_SALEN 0
|
||||||
#define TORRENT_HAS_SEM_RELTIMEDWAIT 1
|
#define TORRENT_HAS_SEM_RELTIMEDWAIT 1
|
||||||
#define TORRENT_HAVE_MMAP 1
|
#define TORRENT_HAVE_MMAP 1
|
||||||
#define TORRENT_USE_SOLARIS_ATOMIC 1
|
|
||||||
|
|
||||||
// ==== BEOS ===
|
// ==== BEOS ===
|
||||||
#elif defined __BEOS__ || defined __HAIKU__
|
#elif defined __BEOS__ || defined __HAIKU__
|
||||||
#define TORRENT_BEOS
|
#define TORRENT_BEOS
|
||||||
#include <storage/StorageDefs.h> // B_PATH_NAME_LENGTH
|
#include <storage/StorageDefs.h> // B_PATH_NAME_LENGTH
|
||||||
#define TORRENT_HAS_FALLOCATE 0
|
#define TORRENT_HAS_FALLOCATE 0
|
||||||
#define TORRENT_USE_BEOS_ATOMIC 1
|
|
||||||
#ifndef TORRENT_USE_ICONV
|
#ifndef TORRENT_USE_ICONV
|
||||||
#define TORRENT_USE_ICONV 0
|
#define TORRENT_USE_ICONV 0
|
||||||
#endif
|
#endif
|
||||||
|
@ -353,16 +346,6 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#define TORRENT_BSD
|
#define TORRENT_BSD
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined __GNUC__ && !(defined TORRENT_USE_OSATOMIC \
|
|
||||||
|| defined TORRENT_USE_INTERLOCKED_ATOMIC \
|
|
||||||
|| defined TORRENT_USE_BEOS_ATOMIC \
|
|
||||||
|| defined TORRENT_USE_SOLARIS_ATOMIC)
|
|
||||||
// atomic operations in GCC were introduced in 4.1.1
|
|
||||||
# if (__GNUC__ >= 4 && __GNUC_MINOR__ >= 1 && __GNUC_PATCHLEVEL__ >= 1) || __GNUC__ > 4
|
|
||||||
# define TORRENT_USE_GCC_ATOMIC 1
|
|
||||||
# endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// on windows, NAME_MAX refers to Unicode characters
|
// on windows, NAME_MAX refers to Unicode characters
|
||||||
// on linux it refers to bytes (utf-8 encoded)
|
// on linux it refers to bytes (utf-8 encoded)
|
||||||
// TODO: Make this count Unicode characters instead of bytes on windows
|
// TODO: Make this count Unicode characters instead of bytes on windows
|
||||||
|
@ -448,22 +431,6 @@ int snprintf(char* buf, int len, char const* fmt, ...)
|
||||||
#define TORRENT_FORMAT(fmt, ellipsis)
|
#define TORRENT_FORMAT(fmt, ellipsis)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef TORRENT_USE_INTERLOCKED_ATOMIC
|
|
||||||
#define TORRENT_USE_INTERLOCKED_ATOMIC 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_USE_GCC_ATOMIC
|
|
||||||
#define TORRENT_USE_GCC_ATOMIC 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_USE_OSATOMIC
|
|
||||||
#define TORRENT_USE_OSATOMIC 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef TORRENT_USE_BEOS_ATOMIC
|
|
||||||
#define TORRENT_USE_BEOS_ATOMIC 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// libiconv presence detection is not implemented yet
|
// libiconv presence detection is not implemented yet
|
||||||
#ifndef TORRENT_USE_ICONV
|
#ifndef TORRENT_USE_ICONV
|
||||||
#define TORRENT_USE_ICONV 1
|
#define TORRENT_USE_ICONV 1
|
||||||
|
|
|
@ -59,7 +59,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
#ifndef TORRENT_DISABLE_POOL_ALLOCATOR
|
||||||
#include <boost/pool/pool.hpp>
|
#include <boost/pool/pool.hpp>
|
||||||
#endif
|
#endif
|
||||||
#include <boost/atomic.hpp>
|
#include <atomic>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
|
@ -518,15 +518,15 @@ namespace libtorrent
|
||||||
// this is a counter which is atomically incremented
|
// this is a counter which is atomically incremented
|
||||||
// by each thread as it's started up, in order to
|
// by each thread as it's started up, in order to
|
||||||
// assign a unique id to each thread
|
// assign a unique id to each thread
|
||||||
boost::atomic<int> m_num_threads;
|
std::atomic<int> m_num_threads;
|
||||||
|
|
||||||
// set to true once we start shutting down
|
// set to true once we start shutting down
|
||||||
boost::atomic<bool> m_abort;
|
std::atomic<bool> m_abort;
|
||||||
|
|
||||||
// this is a counter of how many threads are currently running.
|
// this is a counter of how many threads are currently running.
|
||||||
// it's used to identify the last thread still running while
|
// it's used to identify the last thread still running while
|
||||||
// shutting down. This last thread is responsible for cleanup
|
// shutting down. This last thread is responsible for cleanup
|
||||||
boost::atomic<int> m_num_running_threads;
|
std::atomic<int> m_num_running_threads;
|
||||||
|
|
||||||
// the actual threads running disk jobs
|
// the actual threads running disk jobs
|
||||||
std::vector<std::thread> m_threads;
|
std::vector<std::thread> m_threads;
|
||||||
|
|
|
@ -38,7 +38,9 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <boost/cstdint.hpp>
|
#include <boost/cstdint.hpp>
|
||||||
#include <boost/atomic.hpp>
|
#include <atomic>
|
||||||
|
#include <mutex>
|
||||||
|
#include <array>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
|
@ -451,13 +453,13 @@ namespace libtorrent
|
||||||
// TODO: restore these to regular integers. Instead have one copy
|
// TODO: restore these to regular integers. Instead have one copy
|
||||||
// of the counters per thread and collect them at convenient
|
// of the counters per thread and collect them at convenient
|
||||||
// synchronization points
|
// synchronization points
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
boost::atomic<boost::int64_t> m_stats_counter[num_counters];
|
std::array<std::atomic<boost::int64_t>, num_counters> m_stats_counter;
|
||||||
#else
|
#else
|
||||||
// if the atomic type is't lock-free, use a single lock instead, for
|
// if the atomic type is't lock-free, use a single lock instead, for
|
||||||
// the whole array
|
// the whole array
|
||||||
mutable std::mutex m_mutex;
|
mutable std::mutex m_mutex;
|
||||||
boost::int64_t m_stats_counter[num_counters];
|
std::array<boost::int64_t, num_counters> m_stats_counter;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include <boost/enable_shared_from_this.hpp>
|
#include <boost/enable_shared_from_this.hpp>
|
||||||
#include <boost/scoped_ptr.hpp>
|
#include <boost/scoped_ptr.hpp>
|
||||||
#include <boost/unordered_set.hpp>
|
#include <boost/unordered_set.hpp>
|
||||||
#include <boost/atomic.hpp>
|
#include <atomic>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
|
||||||
|
@ -585,7 +585,7 @@ namespace libtorrent
|
||||||
// to this torrent, currently pending, hanging off of
|
// to this torrent, currently pending, hanging off of
|
||||||
// cached_piece_entry objects. This is used to determine
|
// cached_piece_entry objects. This is used to determine
|
||||||
// when the fence can be lowered
|
// when the fence can be lowered
|
||||||
boost::atomic<int> m_outstanding_jobs;
|
std::atomic<int> m_outstanding_jobs;
|
||||||
|
|
||||||
// must be held when accessing m_has_fence and
|
// must be held when accessing m_has_fence and
|
||||||
// m_blocked_jobs
|
// m_blocked_jobs
|
||||||
|
|
|
@ -36,7 +36,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#ifdef TORRENT_PRODUCTION_ASSERTS
|
#ifdef TORRENT_PRODUCTION_ASSERTS
|
||||||
#include <boost/atomic.hpp>
|
#include <atomic>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|
#if (defined TORRENT_DEBUG && TORRENT_USE_ASSERTS) \
|
||||||
|
@ -220,7 +220,7 @@ TORRENT_EXPORT void print_backtrace(char* out, int len, int max_depth)
|
||||||
char const* libtorrent_assert_log = "asserts.log";
|
char const* libtorrent_assert_log = "asserts.log";
|
||||||
namespace {
|
namespace {
|
||||||
// the number of asserts we've printed to the log
|
// the number of asserts we've printed to the log
|
||||||
boost::atomic<int> assert_counter(0);
|
std::atomic<int> assert_counter(0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -43,10 +43,10 @@ namespace libtorrent {
|
||||||
|
|
||||||
counters::counters()
|
counters::counters()
|
||||||
{
|
{
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
for (int i = 0; i < sizeof(m_stats_counter)
|
for (int i = 0; i < sizeof(m_stats_counter)
|
||||||
/ sizeof(m_stats_counter[0]); ++i)
|
/ sizeof(m_stats_counter[0]); ++i)
|
||||||
m_stats_counter[i].store(0, boost::memory_order_relaxed);
|
m_stats_counter[i].store(0, std::memory_order_relaxed);
|
||||||
#else
|
#else
|
||||||
memset(m_stats_counter, 0, sizeof(m_stats_counter));
|
memset(m_stats_counter, 0, sizeof(m_stats_counter));
|
||||||
#endif
|
#endif
|
||||||
|
@ -54,12 +54,12 @@ namespace libtorrent {
|
||||||
|
|
||||||
counters::counters(counters const& c)
|
counters::counters(counters const& c)
|
||||||
{
|
{
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
for (int i = 0; i < sizeof(m_stats_counter)
|
for (int i = 0; i < sizeof(m_stats_counter)
|
||||||
/ sizeof(m_stats_counter[0]); ++i)
|
/ sizeof(m_stats_counter[0]); ++i)
|
||||||
m_stats_counter[i].store(
|
m_stats_counter[i].store(
|
||||||
c.m_stats_counter[i].load(boost::memory_order_relaxed)
|
c.m_stats_counter[i].load(std::memory_order_relaxed)
|
||||||
, boost::memory_order_relaxed);
|
, std::memory_order_relaxed);
|
||||||
#else
|
#else
|
||||||
std::lock_guard<std::mutex> l(c.m_mutex);
|
std::lock_guard<std::mutex> l(c.m_mutex);
|
||||||
memcpy(m_stats_counter, c.m_stats_counter, sizeof(m_stats_counter));
|
memcpy(m_stats_counter, c.m_stats_counter, sizeof(m_stats_counter));
|
||||||
|
@ -68,12 +68,12 @@ namespace libtorrent {
|
||||||
|
|
||||||
counters& counters::operator=(counters const& c)
|
counters& counters::operator=(counters const& c)
|
||||||
{
|
{
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
for (int i = 0; i < sizeof(m_stats_counter)
|
for (int i = 0; i < sizeof(m_stats_counter)
|
||||||
/ sizeof(m_stats_counter[0]); ++i)
|
/ sizeof(m_stats_counter[0]); ++i)
|
||||||
m_stats_counter[i].store(
|
m_stats_counter[i].store(
|
||||||
c.m_stats_counter[i].load(boost::memory_order_relaxed)
|
c.m_stats_counter[i].load(std::memory_order_relaxed)
|
||||||
, boost::memory_order_relaxed);
|
, std::memory_order_relaxed);
|
||||||
#else
|
#else
|
||||||
std::lock_guard<std::mutex> l(m_mutex);
|
std::lock_guard<std::mutex> l(m_mutex);
|
||||||
std::lock_guard<std::mutex> l2(c.m_mutex);
|
std::lock_guard<std::mutex> l2(c.m_mutex);
|
||||||
|
@ -90,8 +90,8 @@ namespace libtorrent {
|
||||||
VALGRIND_CHECK_VALUE_IS_DEFINED(m_stats_counter[i]);
|
VALGRIND_CHECK_VALUE_IS_DEFINED(m_stats_counter[i]);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
return m_stats_counter[i].load(boost::memory_order_relaxed);
|
return m_stats_counter[i].load(std::memory_order_relaxed);
|
||||||
#else
|
#else
|
||||||
std::lock_guard<std::mutex> l(m_mutex);
|
std::lock_guard<std::mutex> l(m_mutex);
|
||||||
return m_stats_counter[i];
|
return m_stats_counter[i];
|
||||||
|
@ -109,8 +109,8 @@ namespace libtorrent {
|
||||||
TORRENT_ASSERT(c >= 0);
|
TORRENT_ASSERT(c >= 0);
|
||||||
TORRENT_ASSERT(c < num_counters);
|
TORRENT_ASSERT(c < num_counters);
|
||||||
|
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
boost::int64_t pv = m_stats_counter[c].fetch_add(value, boost::memory_order_relaxed);
|
boost::int64_t pv = m_stats_counter[c].fetch_add(value, std::memory_order_relaxed);
|
||||||
TORRENT_ASSERT(pv + value >= 0);
|
TORRENT_ASSERT(pv + value >= 0);
|
||||||
return pv + value;
|
return pv + value;
|
||||||
#else
|
#else
|
||||||
|
@ -129,12 +129,12 @@ namespace libtorrent {
|
||||||
TORRENT_ASSERT(ratio >= 0);
|
TORRENT_ASSERT(ratio >= 0);
|
||||||
TORRENT_ASSERT(ratio <= 100);
|
TORRENT_ASSERT(ratio <= 100);
|
||||||
|
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
boost::int64_t current = m_stats_counter[c].load(boost::memory_order_relaxed);
|
boost::int64_t current = m_stats_counter[c].load(std::memory_order_relaxed);
|
||||||
boost::int64_t new_value = (current * (100-ratio) + value * ratio) / 100;
|
boost::int64_t new_value = (current * (100-ratio) + value * ratio) / 100;
|
||||||
|
|
||||||
while (!m_stats_counter[c].compare_exchange_weak(current, new_value
|
while (!m_stats_counter[c].compare_exchange_weak(current, new_value
|
||||||
, boost::memory_order_relaxed))
|
, std::memory_order_relaxed))
|
||||||
{
|
{
|
||||||
new_value = (current * (100-ratio) + value * ratio) / 100;
|
new_value = (current * (100-ratio) + value * ratio) / 100;
|
||||||
}
|
}
|
||||||
|
@ -150,7 +150,7 @@ namespace libtorrent {
|
||||||
TORRENT_ASSERT(c >= 0);
|
TORRENT_ASSERT(c >= 0);
|
||||||
TORRENT_ASSERT(c < num_counters);
|
TORRENT_ASSERT(c < num_counters);
|
||||||
|
|
||||||
#if BOOST_ATOMIC_LLONG_LOCK_FREE == 2
|
#ifdef ATOMIC_LLONG_LOCK_FREE
|
||||||
m_stats_counter[c].store(value);
|
m_stats_counter[c].store(value);
|
||||||
#else
|
#else
|
||||||
std::lock_guard<std::mutex> l(m_mutex);
|
std::lock_guard<std::mutex> l(m_mutex);
|
||||||
|
|
|
@ -179,7 +179,7 @@ namespace libtorrent
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef TORRENT_DISK_STATS
|
#ifdef TORRENT_DISK_STATS
|
||||||
static boost::atomic<int> event_id;
|
static std::atomic<int> event_id;
|
||||||
static std::mutex disk_access_mutex;
|
static std::mutex disk_access_mutex;
|
||||||
|
|
||||||
// this is opened and closed by the disk_io_thread class
|
// this is opened and closed by the disk_io_thread class
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
#include "libtorrent/disk_io_job.hpp"
|
#include "libtorrent/disk_io_job.hpp"
|
||||||
#include "test.hpp"
|
#include "test.hpp"
|
||||||
|
|
||||||
#include <boost/atomic.hpp>
|
#include <atomic>
|
||||||
|
|
||||||
using namespace libtorrent;
|
using namespace libtorrent;
|
||||||
|
|
||||||
|
|
|
@ -33,7 +33,7 @@ POSSIBILITY OF SUCH DAMAGE.
|
||||||
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
#include "libtorrent/aux_/disable_warnings_push.hpp"
|
||||||
|
|
||||||
#include <boost/bind.hpp>
|
#include <boost/bind.hpp>
|
||||||
#include <boost/atomic.hpp>
|
#include <atomic>
|
||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
#include "libtorrent/aux_/disable_warnings_pop.hpp"
|
||||||
|
@ -52,7 +52,7 @@ void fun(std::condition_variable* s, std::mutex* m, int* waiting, int i)
|
||||||
fprintf(stderr, "thread %d done\n", i);
|
fprintf(stderr, "thread %d done\n", i);
|
||||||
}
|
}
|
||||||
|
|
||||||
void increment(std::condition_variable* s, std::mutex* m, int* waiting, boost::atomic<int>* c)
|
void increment(std::condition_variable* s, std::mutex* m, int* waiting, std::atomic<int>* c)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(*m);
|
std::unique_lock<std::mutex> l(*m);
|
||||||
*waiting += 1;
|
*waiting += 1;
|
||||||
|
@ -62,7 +62,7 @@ void increment(std::condition_variable* s, std::mutex* m, int* waiting, boost::a
|
||||||
++*c;
|
++*c;
|
||||||
}
|
}
|
||||||
|
|
||||||
void decrement(std::condition_variable* s, std::mutex* m, int* waiting, boost::atomic<int>* c)
|
void decrement(std::condition_variable* s, std::mutex* m, int* waiting, std::atomic<int>* c)
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> l(*m);
|
std::unique_lock<std::mutex> l(*m);
|
||||||
*waiting += 1;
|
*waiting += 1;
|
||||||
|
@ -99,7 +99,7 @@ TORRENT_TEST(threads)
|
||||||
threads.clear();
|
threads.clear();
|
||||||
|
|
||||||
waiting = 0;
|
waiting = 0;
|
||||||
boost::atomic<int> c(0);
|
std::atomic<int> c(0);
|
||||||
for (int i = 0; i < 3; ++i)
|
for (int i = 0; i < 3; ++i)
|
||||||
{
|
{
|
||||||
threads.emplace_back(&increment, &cond, &m, &waiting, &c);
|
threads.emplace_back(&increment, &cond, &m, &waiting, &c);
|
||||||
|
|
Loading…
Reference in New Issue