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