@@ -132,7 +132,7 @@ const int WarmupState::LoadingData = 7;
132132const int WarmupState::Done = 8 ;
133133
134134const char *WarmupState::toString (void ) const {
135- return getStateDescription (state);
135+ return getStateDescription (state. load () );
136136}
137137
138138const char *WarmupState::getStateDescription (int st) const {
@@ -164,10 +164,10 @@ void WarmupState::transition(int to, bool allowAnystate) {
164164 if (allowAnystate || legalTransition (to)) {
165165 std::stringstream ss;
166166 ss << " Warmup transition from state \" "
167- << getStateDescription (state) << " \" to \" "
167+ << getStateDescription (state. load () ) << " \" to \" "
168168 << getStateDescription (to) << " \" " ;
169169 LOG (EXTENSION_LOG_DEBUG, " %s" , ss.str ().c_str ());
170- state = to ;
170+ state. store (to) ;
171171 } else {
172172 // Throw an exception to make it possible to test the logic ;)
173173 std::stringstream ss;
@@ -177,7 +177,7 @@ void WarmupState::transition(int to, bool allowAnystate) {
177177}
178178
179179bool WarmupState::legalTransition (int to) const {
180- switch (state) {
180+ switch (state. load () ) {
181181 case Initialize:
182182 return (to == CreateVBuckets);
183183 case CreateVBuckets:
@@ -384,12 +384,12 @@ Warmup::~Warmup() {
384384
385385void Warmup::setEstimatedWarmupCount (size_t to)
386386{
387- estimatedWarmupCount = to ;
387+ estimatedWarmupCount. store (to) ;
388388}
389389
390390size_t Warmup::getEstimatedItemCount ()
391391{
392- return estimatedItemCount;
392+ return estimatedItemCount. load () ;
393393}
394394
395395void Warmup::start (void )
@@ -587,9 +587,9 @@ void Warmup::scheduleCheckForAccessLog()
587587
588588void Warmup::checkForAccessLog ()
589589{
590- metadata = gethrtime () - startTime;
590+ metadata. store ( gethrtime () - startTime) ;
591591 LOG (EXTENSION_LOG_WARNING, " metadata loaded in %s" ,
592- hrtime2text (metadata).c_str ());
592+ hrtime2text (metadata. load () ).c_str ());
593593
594594 if (store->maybeEnableTraffic ()) {
595595 transition (WarmupState::Done);
@@ -629,7 +629,6 @@ void Warmup::scheduleLoadingAccessLog()
629629
630630void Warmup::loadingAccessLog (uint16_t shardId)
631631{
632-
633632 LoadStorageKVPairCallback *load_cb =
634633 new LoadStorageKVPairCallback (store, true , state.getState ());
635634 bool success = false ;
@@ -799,7 +798,7 @@ void Warmup::done()
799798 setWarmupTime ();
800799 store->warmupCompleted ();
801800 LOG (EXTENSION_LOG_WARNING, " warmup completed in %s" ,
802- hrtime2text (warmup).c_str ());
801+ hrtime2text (warmup. load () ).c_str ());
803802 }
804803}
805804
@@ -890,32 +889,36 @@ void Warmup::addStats(ADD_STAT add_stat, const void *c) const
890889 addStat (" min_item_threshold" ,
891890 stats.warmupNumReadCap * 100.0 , add_stat, c);
892891
893- if (metadata > 0 ) {
894- addStat (" keys_time" , metadata / 1000 , add_stat, c);
892+ hrtime_t md_time = metadata.load ();
893+ if (md_time > 0 ) {
894+ addStat (" keys_time" , md_time / 1000 , add_stat, c);
895895 }
896896
897- if (warmup > 0 ) {
898- addStat (" time" , warmup / 1000 , add_stat, c);
897+ hrtime_t w_time = warmup.load ();
898+ if (w_time > 0 ) {
899+ addStat (" time" , w_time / 1000 , add_stat, c);
899900 }
900901
901- if (estimatedItemCount == std::numeric_limits<size_t >::max ()) {
902+ size_t itemCount = estimatedItemCount.load ();
903+ if (itemCount == std::numeric_limits<size_t >::max ()) {
902904 addStat (" estimated_key_count" , " unknown" , add_stat, c);
903905 } else {
904- if (estimateTime != 0 ) {
905- addStat (" estimate_time" , estimateTime / 1000 , add_stat, c);
906+ hrtime_t e_time = estimateTime.load ();
907+ if (e_time != 0 ) {
908+ addStat (" estimate_time" , e_time / 1000 , add_stat, c);
906909 }
907- addStat (" estimated_key_count" , estimatedItemCount , add_stat, c);
910+ addStat (" estimated_key_count" , itemCount , add_stat, c);
908911 }
909912
910913 if (corruptAccessLog) {
911914 addStat (" access_log" , " corrupt" , add_stat, c);
912915 }
913916
914- if (estimatedWarmupCount == std::numeric_limits<size_t >::max ()) {
917+ size_t warmupCount = estimatedWarmupCount.load ();
918+ if (warmupCount == std::numeric_limits<size_t >::max ()) {
915919 addStat (" estimated_value_count" , " unknown" , add_stat, c);
916920 } else {
917- addStat (" estimated_value_count" , estimatedWarmupCount,
918- add_stat, c);
921+ addStat (" estimated_value_count" , warmupCount, add_stat, c);
919922 }
920923 } else {
921924 addStat (NULL , " disabled" , add_stat, c);
0 commit comments