move g_test_dbg_lock_sleep from a global to a function level static

This avoids the need to define that variable in every program
which uses epee.
This commit is contained in:
moneromooo-monero 2016-02-22 19:34:09 +00:00
parent 3860feecb8
commit 5e3557d2c3
No known key found for this signature in database
GPG Key ID: 686F07454D6CEFC3
18 changed files with 13 additions and 37 deletions

View File

@ -39,7 +39,14 @@
namespace epee namespace epee
{ {
extern unsigned int g_test_dbg_lock_sleep; namespace debug
{
inline unsigned int &g_test_dbg_lock_sleep()
{
static unsigned int value = 0;
return value;
}
}
struct simple_event struct simple_event
{ {
@ -217,10 +224,10 @@ namespace epee
#define SHARED_CRITICAL_REGION_BEGIN(x) { shared_guard critical_region_var(x) #define SHARED_CRITICAL_REGION_BEGIN(x) { shared_guard critical_region_var(x)
#define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { exclusive_guard critical_region_var(x) #define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { exclusive_guard critical_region_var(x)
#define CRITICAL_REGION_LOCAL(x) {std::this_thread::sleep_for(std::chrono::milliseconds(epee::g_test_dbg_lock_sleep));} epee::critical_region_t<decltype(x)> critical_region_var(x) #define CRITICAL_REGION_LOCAL(x) {std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep()));} epee::critical_region_t<decltype(x)> critical_region_var(x)
#define CRITICAL_REGION_BEGIN(x) { std::this_thread::sleep_for(std::chrono::milliseconds(epee::g_test_dbg_lock_sleep)); epee::critical_region_t<decltype(x)> critical_region_var(x) #define CRITICAL_REGION_BEGIN(x) { std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep())); epee::critical_region_t<decltype(x)> critical_region_var(x)
#define CRITICAL_REGION_LOCAL1(x) {std::this_thread::sleep_for(std::chrono::milliseconds(epee::g_test_dbg_lock_sleep));} epee::critical_region_t<decltype(x)> critical_region_var1(x) #define CRITICAL_REGION_LOCAL1(x) {std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep()));} epee::critical_region_t<decltype(x)> critical_region_var1(x)
#define CRITICAL_REGION_BEGIN1(x) { std::this_thread::sleep_for(std::chrono::milliseconds(epee::g_test_dbg_lock_sleep)); epee::critical_region_t<decltype(x)> critical_region_var1(x) #define CRITICAL_REGION_BEGIN1(x) { std::this_thread::sleep_for(std::chrono::milliseconds(epee::debug::g_test_dbg_lock_sleep())); epee::critical_region_t<decltype(x)> critical_region_var1(x)
#define CRITICAL_REGION_END() } #define CRITICAL_REGION_END() }

View File

@ -45,8 +45,6 @@
#include <iostream> #include <iostream>
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace namespace
{ {

View File

@ -38,8 +38,6 @@
#include "common/command_line.h" #include "common/command_line.h"
#include "version.h" #include "version.h"
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace po = boost::program_options; namespace po = boost::program_options;
using namespace epee; // log_space using namespace epee; // log_space

View File

@ -31,8 +31,6 @@
#include "common/command_line.h" #include "common/command_line.h"
#include "version.h" #include "version.h"
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace po = boost::program_options; namespace po = boost::program_options;
using namespace epee; // log_space using namespace epee; // log_space

View File

@ -44,8 +44,6 @@
#include "fake_core.h" #include "fake_core.h"
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace namespace
{ {
// CONFIG // CONFIG

View File

@ -32,8 +32,6 @@
#include "common/command_line.h" #include "common/command_line.h"
#include "version.h" #include "version.h"
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace po = boost::program_options; namespace po = boost::program_options;
using namespace epee; // log_space using namespace epee; // log_space

View File

@ -49,8 +49,6 @@ namespace po = boost::program_options;
using namespace cryptonote; using namespace cryptonote;
using namespace nodetool; using namespace nodetool;
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace namespace
{ {
const command_line::arg_descriptor<std::string, true> arg_ip = {"ip", "set ip"}; const command_line::arg_descriptor<std::string, true> arg_ip = {"ip", "set ip"};

View File

@ -46,8 +46,6 @@ using namespace epee;
#include <functional> #include <functional>
unsigned int epee::g_test_dbg_lock_sleep = 0;
namespace daemonize { namespace daemonize {
struct t_internals { struct t_internals {

View File

@ -132,7 +132,7 @@ int main(int argc, char const * argv[])
return 0; return 0;
} }
epee::g_test_dbg_lock_sleep = command_line::get_arg(vm, command_line::arg_test_dbg_lock_sleep); epee::debug::g_test_dbg_lock_sleep() = command_line::get_arg(vm, command_line::arg_test_dbg_lock_sleep);
std::string db_type = command_line::get_arg(vm, command_line::arg_db_type); std::string db_type = command_line::get_arg(vm, command_line::arg_db_type);

View File

@ -41,7 +41,6 @@
using namespace epee; using namespace epee;
namespace po = boost::program_options; namespace po = boost::program_options;
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {

View File

@ -73,8 +73,6 @@ typedef cryptonote::simple_wallet sw;
#define EXTENDED_LOGS_FILE "wallet_details.log" #define EXTENDED_LOGS_FILE "wallet_details.log"
unsigned int epee::g_test_dbg_lock_sleep = 0;
#define DEFAULT_MIX 4 #define DEFAULT_MIX 4
namespace namespace

View File

@ -62,8 +62,6 @@ using namespace crypto;
BOOST_CLASS_VERSION(nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> >, 1); BOOST_CLASS_VERSION(nodetool::node_server<cryptonote::t_cryptonote_protocol_handler<tests::proxy_core> >, 1);
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {

View File

@ -44,8 +44,6 @@ namespace
const command_line::arg_descriptor<bool> arg_test_transactions = {"test_transactions", ""}; const command_line::arg_descriptor<bool> arg_test_transactions = {"test_transactions", ""};
} }
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
TRY_ENTRY(); TRY_ENTRY();

View File

@ -55,8 +55,6 @@ namespace
const command_line::arg_descriptor<size_t> arg_test_repeat_count = {"test_repeat_count", "", 1}; const command_line::arg_descriptor<size_t> arg_test_repeat_count = {"test_repeat_count", "", 1};
} }
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char* argv[]) int main(int argc, char* argv[])
{ {
TRY_ENTRY(); TRY_ENTRY();

View File

@ -628,8 +628,6 @@ TEST_F(net_load_test_clt, permament_open_and_close_and_connections_closed_by_ser
ASSERT_EQ(RESERVED_CONN_CNT, m_tcp_server.get_config_object().get_connections_count()); ASSERT_EQ(RESERVED_CONN_CNT, m_tcp_server.get_config_object().get_connections_count());
} }
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
epee::debug::get_set_enable_assert(true, false); epee::debug::get_set_enable_assert(true, false);

View File

@ -213,8 +213,6 @@ namespace
}; };
} }
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
//set up logging options //set up logging options

View File

@ -42,8 +42,6 @@
#include "generate_key_image_helper.h" #include "generate_key_image_helper.h"
#include "is_out_to_acc.h" #include "is_out_to_acc.h"
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
set_process_affinity(1); set_process_affinity(1);

View File

@ -32,8 +32,6 @@
#include "include_base_utils.h" #include "include_base_utils.h"
unsigned int epee::g_test_dbg_lock_sleep = 0;
int main(int argc, char** argv) int main(int argc, char** argv)
{ {
epee::debug::get_set_enable_assert(true, false); epee::debug::get_set_enable_assert(true, false);