zhaojinzhou commented on issue #3070:
URL: https://github.com/apache/brpc/issues/3070#issuecomment-3218073531

   !!!       实锤,以下代码 会死锁。   碰到赋值语句,立刻死锁。 希望尽早修复
   
   
   #include <iostream>
   #include <vector>
   #include <atomic>
   #include <memory>
   #include <random>
   
   inline uint64_t find_power2(uint64_t b) {
       b -= 1;
       b |= (b >> 1);
       b |= (b >> 2);
       b |= (b >> 4);
       b |= (b >> 8);
       b |= (b >> 16);
       b |= (b >> 32);
       return b + 1;
   }
   
   inline size_t flatmap_round(size_t nbucket) {
   #ifdef FLAT_MAP_ROUND_BUCKET_BY_USE_NEXT_PRIME    
       return find_next_prime(nbucket);
   #else
       // the lowerbound fixes the corner case of nbucket=0 which results in 
coredump during seeking the map.
       return nbucket <= 8 ? 8 : find_power2(nbucket);
   #endif
   }
   
   static bool is_too_crowded(size_t size, size_t nbucket, uint32_t 
load_factor) {
           return size * 100 >= nbucket * load_factor;
       }
       
   int main() {
       size_t new_nbucket  =16;
       size_t size = 14;
       do {
            new_nbucket = flatmap_round(16);
           static int i=0;
           i++;
           if (i % 1000 == 0) {
             std::cout << "new_buckets_and_thumbnail: ";
           }
       } while (is_too_crowded(size, new_nbucket, 80));
   
   }


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to