Commit 603077ea authored by Matthew Hausknecht's avatar Matthew Hausknecht

Threadsafe library update. Requires c++11

parent 90625ed0
......@@ -5,7 +5,7 @@ include(ExternalProject)
option(BUILD_SOCCERWINDOW "Build Soccerwindow Visualizer" ON)
option(INSTALL_ADDITIONAL_TEAMS "Install additional team binaries" ON)
add_definitions(-DELOG)
add_definitions(-DELOG -std=c++11)
ExternalProject_Add(rcssserver
GIT_REPOSITORY "https://github.com/mhauskn/rcssserver.git"
......
......@@ -193,9 +193,9 @@ Bhv_BasicTackle::executeOld( PlayerAgent * agent )
bool
Bhv_BasicTackle::executeV12( PlayerAgent * agent )
{
static GameTime s_last_execute_time( 0, 0 );
static bool s_result = false;
static AngleDeg s_best_angle = 0.0;
static thread_local GameTime s_last_execute_time( 0, 0 );
static thread_local bool s_result = false;
static thread_local AngleDeg s_best_angle = 0.0;
const WorldModel & wm = agent->world();
......
......@@ -122,11 +122,11 @@ Force_Pass::get_best_pass( const WorldModel & world,
double * first_speed,
int * receiver )
{
static GameTime S_last_calc_time( 0, 0 );
static bool S_last_calc_valid = false;
static Vector2D S_last_calc_target;
static double S_last_calc_speed = 0.0;
static int S_last_calc_receiver = Unum_Unknown;
static thread_local GameTime S_last_calc_time( 0, 0 );
static thread_local bool S_last_calc_valid = false;
static thread_local Vector2D S_last_calc_target;
static thread_local double S_last_calc_speed = 0.0;
static thread_local int S_last_calc_receiver = Unum_Unknown;
if ( S_last_calc_time == world.time() )
{
......@@ -208,11 +208,11 @@ bool
Force_Pass::get_pass_to_player( const WorldModel & world,
int receiver_unum )
{
static GameTime S_last_calc_time( 0, 0 );
static bool S_last_calc_valid = false;
static Vector2D S_last_calc_target;
static double S_last_calc_speed = 0.0;
static int S_last_calc_receiver = Unum_Unknown;
static thread_local GameTime S_last_calc_time( 0, 0 );
static thread_local bool S_last_calc_valid = false;
static thread_local Vector2D S_last_calc_target;
static thread_local double S_last_calc_speed = 0.0;
static thread_local int S_last_calc_receiver = Unum_Unknown;
if ( S_last_calc_time == world.time() )
{
......
......@@ -53,9 +53,9 @@
bool
Bhv_GoalieFreeKick::execute( rcsc::PlayerAgent * agent )
{
static bool s_first_move = false;
static bool s_second_move = false;
static int s_second_wait_count = 0;
static thread_local bool s_first_move = false;
static thread_local bool s_second_move = false;
static thread_local int s_second_wait_count = 0;
rcsc::dlog.addText( rcsc::Logger::TEAM,
__FILE__": Bhf_GoalieFreeKick" );
......
......@@ -622,7 +622,7 @@ bool
Bhv_PenaltyKick::doDribble( PlayerAgent * agent )
{
static const int CONTINUAL_COUNT = 20;
static int S_target_continual_count = CONTINUAL_COUNT;
static thread_local int S_target_continual_count = CONTINUAL_COUNT;
const ServerParam & SP = ServerParam::i();
const WorldModel & wm = agent->world();
......
......@@ -51,7 +51,7 @@ using namespace rcsc;
bool
Bhv_PrepareSetPlayKick::execute( PlayerAgent * agent )
{
static int s_rest_wait_cycle = -1;
static thread_local int s_rest_wait_cycle = -1;
// not reach the ball side
if ( Bhv_GoToStaticBall( M_ball_place_angle ).execute( agent ) )
......
......@@ -113,8 +113,8 @@ ActGen_DirectPass::generate( std::vector< ActionStatePair > * result,
const std::vector< ActionStatePair > & path ) const
{
static const int VALID_PLAYER_THRESHOLD = 10;
static GameTime s_last_call_time( 0, 0 );
static int s_action_count = 0;
static thread_local GameTime s_last_call_time( 0, 0 );
static thread_local int s_action_count = 0;
if ( current_wm.time() != s_last_call_time )
{
......
......@@ -56,8 +56,8 @@ ActGen_SimpleDribble::generate( std::vector< ActionStatePair > * result,
const WorldModel & current_wm,
const std::vector< ActionStatePair > & path ) const
{
static GameTime s_last_call_time( 0, 0 );
static int s_action_count = 0;
static thread_local GameTime s_last_call_time( 0, 0 );
static thread_local int s_action_count = 0;
if ( current_wm.time() != s_last_call_time )
{
......
......@@ -57,7 +57,7 @@ ActionChainHolder::ActionChainHolder()
ActionChainHolder &
ActionChainHolder::instance()
{
static ActionChainHolder s_instance;
static thread_local ActionChainHolder s_instance;
return s_instance;
}
......@@ -119,9 +119,9 @@ ActionChainHolder::actionGenerator() const
void
ActionChainHolder::update( const WorldModel & wm )
{
static GameTime s_update_time( 0, 0 );
static FieldEvaluator::ConstPtr s_update_evaluator;
static ActionGenerator::ConstPtr s_update_generator;
static thread_local GameTime s_update_time( 0, 0 );
static thread_local FieldEvaluator::ConstPtr s_update_evaluator;
static thread_local ActionGenerator::ConstPtr s_update_generator;
if ( s_update_time == wm.time()
&& s_update_evaluator == M_evaluator
......
......@@ -484,8 +484,8 @@ Bhv_ChainAction::doTurnToForward( PlayerAgent * agent )
Vector2D
Bhv_ChainAction::getKeepBallVel( const WorldModel & wm )
{
static GameTime s_update_time( 0, 0 );
static Vector2D s_best_ball_vel( 0.0, 0.0 );
static thread_local GameTime s_update_time( 0, 0 );
static thread_local Vector2D s_best_ball_vel( 0.0, 0.0 );
if ( s_update_time == wm.time() )
{
......
......@@ -661,8 +661,8 @@ Bhv_PassKickFindReceiver::doKeepBall( rcsc::PlayerAgent * agent,
rcsc::Vector2D
Bhv_PassKickFindReceiver::getKeepBallVel( const rcsc::WorldModel & wm )
{
static GameTime s_update_time( 0, 0 );
static Vector2D s_best_ball_vel( 0.0, 0.0 );
static thread_local GameTime s_update_time( 0, 0 );
static thread_local Vector2D s_best_ball_vel( 0.0, 0.0 );
if ( s_update_time == wm.time() )
{
......
......@@ -73,7 +73,7 @@ ClearGenerator::ClearGenerator()
ClearGenerator &
ClearGenerator::instance()
{
static ClearGenerator s_instance;
static thread_local ClearGenerator s_instance;
return s_instance;
}
......
......@@ -91,7 +91,7 @@ CrossGenerator::CrossGenerator()
CrossGenerator &
CrossGenerator::instance()
{
static CrossGenerator s_instance;
static thread_local CrossGenerator s_instance;
return s_instance;
}
......@@ -117,7 +117,7 @@ CrossGenerator::clear()
void
CrossGenerator::generate( const WorldModel & wm )
{
static GameTime s_update_time( -1, 0 );
static thread_local GameTime s_update_time( -1, 0 );
if ( s_update_time == wm.time() )
{
return;
......
......@@ -72,7 +72,7 @@ FieldAnalyzer::FieldAnalyzer()
FieldAnalyzer &
FieldAnalyzer::instance()
{
static FieldAnalyzer s_instance;
static thread_local FieldAnalyzer s_instance;
return s_instance;
}
......@@ -1204,7 +1204,7 @@ FieldAnalyzer::get_blocker( const WorldModel & wm,
void
FieldAnalyzer::update( const WorldModel & wm )
{
static GameTime s_update_time( 0, 0 );
static thread_local GameTime s_update_time( 0, 0 );
if ( s_update_time == wm.time() )
{
......
......@@ -96,7 +96,7 @@ SelfPassGenerator::SelfPassGenerator()
SelfPassGenerator &
SelfPassGenerator::instance()
{
static SelfPassGenerator s_instance;
static thread_local SelfPassGenerator s_instance;
return s_instance;
}
......@@ -166,7 +166,7 @@ SelfPassGenerator::createCourses( const WorldModel & wm )
static const int ANGLE_DIVS = 60;
static const double ANGLE_STEP = 360.0 / ANGLE_DIVS;
static std::vector< Vector2D > self_cache( 24 );
static thread_local std::vector< Vector2D > self_cache( 24 );
const ServerParam & SP = ServerParam::i();
......
......@@ -76,7 +76,7 @@ ShootGenerator::ShootGenerator()
ShootGenerator &
ShootGenerator::instance()
{
static ShootGenerator s_instance;
static thread_local ShootGenerator s_instance;
return s_instance;
}
......@@ -98,7 +98,7 @@ ShootGenerator::clear()
void
ShootGenerator::generate( const WorldModel & wm, bool consider_shot_distance )
{
static GameTime s_update_time( 0, 0 );
static thread_local GameTime s_update_time( 0, 0 );
if ( s_update_time == wm.time() )
{
......
......@@ -98,7 +98,7 @@ ShortDribbleGenerator::ShortDribbleGenerator()
ShortDribbleGenerator &
ShortDribbleGenerator::instance()
{
static ShortDribbleGenerator s_instance;
static thread_local ShortDribbleGenerator s_instance;
return s_instance;
}
......@@ -526,7 +526,7 @@ ShortDribbleGenerator::simulateKickTurnsDashes( const WorldModel & wm,
static const int min_dash = 2;
//static const int min_dash = 1;
static std::vector< Vector2D > self_cache;
static thread_local std::vector< Vector2D > self_cache;
//
// create self position cache
......
......@@ -153,7 +153,7 @@ StrictCheckPassGenerator::StrictCheckPassGenerator()
StrictCheckPassGenerator &
StrictCheckPassGenerator::instance()
{
static StrictCheckPassGenerator s_instance;
static thread_local StrictCheckPassGenerator s_instance;
return s_instance;
}
......
......@@ -184,7 +184,7 @@ TackleGenerator::TackleGenerator()
TackleGenerator &
TackleGenerator::instance()
{
static TackleGenerator s_instance;
static thread_local TackleGenerator s_instance;
return s_instance;
}
......@@ -206,7 +206,7 @@ TackleGenerator::clear()
void
TackleGenerator::generate( const WorldModel & wm )
{
static GameTime s_update_time( 0, 0 );
static thread_local GameTime s_update_time( 0, 0 );
if ( s_update_time == wm.time() )
{
......
......@@ -248,7 +248,7 @@ SampleCoach::handlePlayerType()
void
SampleCoach::doSubstitute()
{
static bool S_first_substituted = false;
static thread_local bool S_first_substituted = false;
if ( ! S_first_substituted
&& world().time().cycle() == 0
......@@ -646,7 +646,7 @@ SampleCoach::sayPlayerTypes()
(say (freeform "(player_type ...)"))
*/
static GameTime s_last_send_time( 0, 0 );
static thread_local GameTime s_last_send_time( 0, 0 );
if ( ! config().useFreeform() )
{
......
......@@ -1534,7 +1534,7 @@ SampleCommunication::sayDefenseLine( PlayerAgent * agent )
bool
SampleCommunication::sayPlayers( PlayerAgent * agent )
{
static GameTime s_last_time( -1, 0 );
static thread_local GameTime s_last_time( -1, 0 );
const int len = agent->effector().getSayMessageLength();
if ( len + OnePlayerMessage::slength() > ServerParam::i().playerSayMsgSize() )
......
......@@ -132,10 +132,10 @@ SampleTrainer::sampleAction()
{
// sample training to test a ball interception.
static int s_state = 0;
static int s_wait_counter = 0;
static thread_local int s_state = 0;
static thread_local int s_wait_counter = 0;
static Vector2D s_last_player_move_pos;
static thread_local Vector2D s_last_player_move_pos;
if ( world().existKickablePlayer() )
{
......@@ -171,7 +171,7 @@ SampleTrainer::sampleAction()
}
// change player type
{
static int type = 0;
static thread_local int type = 0;
doChangePlayerType( world().teamNameLeft(), 1, type );
type = ( type + 1 ) % PlayerParam::i().playerTypes();
}
......@@ -233,7 +233,7 @@ SampleTrainer::recoverForever()
void
SampleTrainer::doSubstitute()
{
static bool s_substitute = false;
static thread_local bool s_substitute = false;
if ( ! s_substitute
&& world().time().cycle() == 0
&& world().time().stopped() >= 10 )
......@@ -257,7 +257,7 @@ SampleTrainer::doSubstitute()
&& world().time().cycle() % 100 == 1
&& ! world().teamNameLeft().empty() )
{
static int type = 0;
static thread_local int type = 0;
doChangePlayerType( world().teamNameLeft(), 1, type );
type = ( type + 1 ) % PlayerParam::i().playerTypes();
}
......
......@@ -56,7 +56,7 @@
SoccerRole::Creators &
SoccerRole::creators()
{
static Creators s_instance;
static thread_local Creators s_instance;
return s_instance;
}
......
......@@ -140,7 +140,7 @@ Strategy::Strategy()
Strategy &
Strategy::instance()
{
static Strategy s_instance;
static thread_local Strategy s_instance;
return s_instance;
}
......@@ -183,7 +183,7 @@ Strategy::init( CmdLineParser & cmd_parser )
bool
Strategy::read( const std::string & formation_dir )
{
static bool s_initialized = false;
static thread_local bool s_initialized = false;
if ( s_initialized )
{
......@@ -434,7 +434,7 @@ Strategy::createFormation( const std::string & type_name ) const
void
Strategy::update( const WorldModel & wm )
{
static GameTime s_update_time( -1, 0 );
static thread_local GameTime s_update_time( -1, 0 );
if ( s_update_time == wm.time() )
{
......@@ -625,7 +625,7 @@ Strategy::updateSituation( const WorldModel & wm )
void
Strategy::updatePosition( const WorldModel & wm )
{
static GameTime s_update_time( 0, 0 );
static thread_local GameTime s_update_time( 0, 0 );
if ( s_update_time == wm.time() )
{
return;
......@@ -1129,7 +1129,7 @@ Strategy::get_ball_area( const Vector2D & ball_pos )
double
Strategy::get_normal_dash_power( const WorldModel & wm )
{
static bool s_recover_mode = false;
static thread_local bool s_recover_mode = false;
if ( wm.self().staminaModel().capacityIsEmpty() )
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment