| 503 | } |
| 504 | |
| 505 | int get_thread_local_keytable_list_length(bthread_keytable_pool_t* pool) { |
| 506 | if (pool == NULL) { |
| 507 | LOG(ERROR) << "Param[pool] is NULL"; |
| 508 | return EINVAL; |
| 509 | } |
| 510 | int length = 0; |
| 511 | pthread_rwlock_rdlock(&pool->rwlock); |
| 512 | if (pool->destroyed) { |
| 513 | pthread_rwlock_unlock(&pool->rwlock); |
| 514 | return length; |
| 515 | } |
| 516 | auto list = (butil::ThreadLocal<bthread::KeyTableList>*)pool->list; |
| 517 | if (list) { |
| 518 | length = (int)(list->get()->get_length()); |
| 519 | if (!list->get()->check_length()) { |
| 520 | LOG(ERROR) << "Length is not equal"; |
| 521 | } |
| 522 | } |
| 523 | pthread_rwlock_unlock(&pool->rwlock); |
| 524 | return length; |
| 525 | } |
| 526 | |
| 527 | // TODO: this is not strict `reserve' because we only check #free. |
| 528 | // Currently there's no way to track KeyTables that may be returned |