1
This commit is contained in:
parent
18a1238512
commit
787f6a5faf
@ -45,19 +45,18 @@ namespace a8
|
||||
} else {
|
||||
size_t index = GetIndex(real_len);
|
||||
|
||||
list_head* free_node = nullptr;
|
||||
BufHead* buf_head = nullptr;
|
||||
{
|
||||
lock_.lock();
|
||||
free_node = &free_list_[index];
|
||||
if (list_empty(free_node)) {
|
||||
free_node = nullptr;
|
||||
} else {
|
||||
list_del(free_node);
|
||||
list_head* head = &free_list_[index];
|
||||
if (!list_empty(head)) {
|
||||
buf_head = list_first_entry(head, BufHead, entry);
|
||||
list_del(&buf_head->entry);
|
||||
}
|
||||
lock_.unlock();
|
||||
}
|
||||
if (free_node) {
|
||||
return (char*)free_node + sizeof(BufHead);
|
||||
if (buf_head) {
|
||||
return (char*)buf_head + sizeof(BufHead);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ namespace a8
|
||||
|
||||
char* buf_ = nullptr;
|
||||
int buf_len_ = 0;
|
||||
std::atomic<int> offset_ = 0;
|
||||
|
||||
a8::SpinLock lock_;
|
||||
std::array<list_head, 10> free_list_;
|
||||
|
Loading…
x
Reference in New Issue
Block a user