wwbmmm commented on code in PR #2479: URL: https://github.com/apache/brpc/pull/2479#discussion_r1436806078
########## src/bthread/list_of_abafree_id.h: ########## @@ -59,18 +61,19 @@ namespace bthread { Review Comment: 上面示例加上 INIT_GC_SIZE ########## src/bthread/list_of_abafree_id.h: ########## @@ -59,18 +61,19 @@ namespace bthread { // This container is NOT thread-safe right now, and shouldn't be // an issue in current usages throughout brpc. -template <typename Id, typename IdTraits> +template <typename Id, typename IdTraits> Review Comment: 无关改动 ########## src/bthread/list_of_abafree_id.h: ########## @@ -140,6 +155,18 @@ int ListOfABAFreeId<Id, IdTraits>::add(Id id) { } saved_pos[i] = pos; } + if (_nblock * IdTraits::BLOCK_SIZE > IdTraits::MAX_ENTRIES) { + return EAGAIN; + } + // Review Comment: 多余注释 ########## src/bthread/list_of_abafree_id.h: ########## @@ -15,27 +15,29 @@ // specific language governing permissions and limitations // under the License. -// bthread - An M:N threading library to make applications more concurrent. +// bthread - A M:N threading library to make applications more concurrent. Review Comment: 这个不用改吧 ########## src/bthread/list_of_abafree_id.h: ########## @@ -140,6 +155,18 @@ int ListOfABAFreeId<Id, IdTraits>::add(Id id) { } saved_pos[i] = pos; } + if (_nblock * IdTraits::BLOCK_SIZE > IdTraits::MAX_ENTRIES) { + return EAGAIN; + } + // + if (_nblock * IdTraits::BLOCK_SIZE > _next_gc_size) { + uint32_t before_gc_blocks = _nblock; + int rc = gc(); + if ((before_gc_blocks - _nblock) * IdTraits::BLOCK_SIZE < (_next_gc_size - (_next_gc_size >> 3))) { Review Comment: 为什么是 >> 3,解释一下? ########## src/bthread/list_of_abafree_id.h: ########## @@ -15,27 +15,29 @@ // specific language governing permissions and limitations // under the License. -// bthread - An M:N threading library to make applications more concurrent. +// bthread - A M:N threading library to make applications more concurrent. // Date: Mon Jun 20 11:57:23 CST 2016 #ifndef BTHREAD_LIST_OF_ABAFREE_ID_H #define BTHREAD_LIST_OF_ABAFREE_ID_H -#include <vector> #include <deque> +#include <vector> + +#include "butil/macros.h" namespace bthread { // A container for storing identifiers that may be invalidated. // [Basic Idea] -// identifiers are remembered for error notifications. While insertions are -// easy, removals are hard to be done in O(1) time. More importantly, +// identifiers are remembered for error notifications. While insertions are Review Comment: 无关改动 -- 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: dev-unsubscr...@brpc.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@brpc.apache.org For additional commands, e-mail: dev-h...@brpc.apache.org