Rename size() to calc_size() for WaitFree hash tables.

This commit is contained in:
levlam 2022-11-18 13:16:24 +03:00
parent 35a9a4b785
commit f8e2af3f59
7 changed files with 12 additions and 12 deletions

View File

@ -3707,10 +3707,10 @@ void ContactsManager::start_up() {
void ContactsManager::tear_down() { void ContactsManager::tear_down() {
parent_.reset(); parent_.reset();
LOG(DEBUG) << "Have " << users_.size() << " users, " << chats_.size() << " basic groups, " << channels_.size() LOG(DEBUG) << "Have " << users_.calc_size() << " users, " << chats_.calc_size() << " basic groups, "
<< " supergroups and " << secret_chats_.size() << " secret chats to free"; << channels_.calc_size() << " supergroups and " << secret_chats_.calc_size() << " secret chats to free";
LOG(DEBUG) << "Have " << users_full_.size() << " full users, " << chats_full_.size() << " full basic groups and " LOG(DEBUG) << "Have " << users_full_.calc_size() << " full users, " << chats_full_.calc_size()
<< channels_full_.size() << " full supergroups to free"; << " full basic groups and " << channels_full_.calc_size() << " full supergroups to free";
} }
UserId ContactsManager::load_my_id() { UserId ContactsManager::load_my_id() {

View File

@ -13541,7 +13541,7 @@ class MessagesManager::DialogFiltersLogEvent {
void MessagesManager::tear_down() { void MessagesManager::tear_down() {
parent_.reset(); parent_.reset();
LOG(DEBUG) << "Have " << dialogs_.size() << " chats with " << added_message_count_ << " messages to free"; LOG(DEBUG) << "Have " << dialogs_.calc_size() << " chats with " << added_message_count_ << " messages to free";
} }
void MessagesManager::hangup() { void MessagesManager::hangup() {

View File

@ -414,7 +414,7 @@ WebPagesManager::WebPagesManager(Td *td, ActorShared<> parent) : td_(td), parent
void WebPagesManager::tear_down() { void WebPagesManager::tear_down() {
parent_.reset(); parent_.reset();
LOG(DEBUG) << "Have " << web_pages_.size() << " web pages to free"; LOG(DEBUG) << "Have " << web_pages_.calc_size() << " web pages to free";
} }
WebPagesManager::~WebPagesManager() { WebPagesManager::~WebPagesManager() {

View File

@ -161,14 +161,14 @@ class WaitFreeHashMap {
} }
} }
size_t size() const { size_t calc_size() const {
if (wait_free_storage_ == nullptr) { if (wait_free_storage_ == nullptr) {
return default_map_.size(); return default_map_.size();
} }
size_t result = 0; size_t result = 0;
for (size_t i = 0; i < MAX_STORAGE_COUNT; i++) { for (size_t i = 0; i < MAX_STORAGE_COUNT; i++) {
result += wait_free_storage_->maps_[i].size(); result += wait_free_storage_->maps_[i].calc_size();
} }
return result; return result;
} }

View File

@ -96,14 +96,14 @@ class WaitFreeHashSet {
} }
} }
size_t size() const { size_t calc_size() const {
if (wait_free_storage_ == nullptr) { if (wait_free_storage_ == nullptr) {
return default_set_.size(); return default_set_.size();
} }
size_t result = 0; size_t result = 0;
for (size_t i = 0; i < MAX_STORAGE_COUNT; i++) { for (size_t i = 0; i < MAX_STORAGE_COUNT; i++) {
result += wait_free_storage_->sets_[i].size(); result += wait_free_storage_->sets_[i].calc_size();
} }
return result; return result;
} }

View File

@ -26,7 +26,7 @@ TEST(WaitFreeHashMap, stress_test) {
auto check = [&](bool check_size = false) { auto check = [&](bool check_size = false) {
if (check_size) { if (check_size) {
ASSERT_EQ(reference.size(), map.size()); ASSERT_EQ(reference.size(), map.calc_size());
} }
ASSERT_EQ(reference.empty(), map.empty()); ASSERT_EQ(reference.empty(), map.empty());

View File

@ -26,7 +26,7 @@ TEST(WaitFreeHashSet, stress_test) {
auto check = [&](bool check_size = false) { auto check = [&](bool check_size = false) {
if (check_size) { if (check_size) {
ASSERT_EQ(reference.size(), set.size()); ASSERT_EQ(reference.size(), set.calc_size());
} }
ASSERT_EQ(reference.empty(), set.empty()); ASSERT_EQ(reference.empty(), set.empty());