提交 04c83f49 编写于 作者: H Hongze Cheng

more

上级 0eff683d
......@@ -65,30 +65,21 @@ extern "C" {
} \
(l)->neles_ += 1;
#define tlistPop(l, n) \
({ \
if ((n)) { \
if ((l)->head_ == (n)) { \
(l)->head_ = (n)->next_; \
} \
if ((l)->tail_ == (n)) { \
(l)->tail_ = (n)->prev_; \
} \
if ((n)->prev_ != NULL) { \
(n)->prev_->next_ = (n)->next_; \
} \
if ((n)->next_ != NULL) { \
(n)->next_->prev_ = (n)->prev_; \
} \
(l)->neles_ -= 1; \
(n)->prev_ = (n)->next_ = NULL; \
} \
(n); \
})
#define tlistPopHead(l) tlistPop(l, (l)->head_)
#define tlistPopTail(l) tlistPop(l, (l)->tail_)
#define tlistPop(l, n) \
if ((l)->head_ == (n)) { \
(l)->head_ = (n)->next_; \
} \
if ((l)->tail_ == (n)) { \
(l)->tail_ = (n)->prev_; \
} \
if ((n)->prev_ != NULL) { \
(n)->prev_->next_ = (n)->next_; \
} \
if ((n)->next_ != NULL) { \
(n)->next_->prev_ = (n)->prev_; \
} \
(l)->neles_ -= 1; \
(n)->prev_ = (n)->next_ = NULL;
// List iterator
#define TD_LIST_FITER 0
......
......@@ -43,9 +43,10 @@ SVMemAllocator *vmaCreate(uint64_t capacity, uint64_t ssize, uint64_t lsize) {
void vmaDestroy(SVMemAllocator *pVMA) {
if (pVMA) {
while (true) {
SVArenaNode *pNode = tlistPopTail(&(pVMA->nlist));
SVArenaNode *pNode = tlistTail(&(pVMA->nlist));
if (pNode) {
tlistPop(&(pVMA->nlist), pNode);
vArenaNodeFree(pNode);
} else {
break;
......@@ -58,7 +59,8 @@ void vmaDestroy(SVMemAllocator *pVMA) {
void vmaReset(SVMemAllocator *pVMA) {
while (tlistNEles(&(pVMA->nlist)) > 1) {
SVArenaNode *pNode = tlistPopTail(&(pVMA->nlist));
SVArenaNode *pNode = tlistTail(&(pVMA->nlist));
tlistPop(&(pVMA->nlist), pNode);
vArenaNodeFree(pNode);
}
......
......@@ -61,14 +61,16 @@ void vnodeCloseBufPool(SVnode *pVnode) {
vmaDestroy(pVnode->pBufPool->inuse);
while (true) {
SVMemAllocator *pVMA = tlistPopHead(&(pVnode->pBufPool->incycle));
SVMemAllocator *pVMA = tlistHead(&(pVnode->pBufPool->incycle));
if (pVMA == NULL) break;
tlistPop(&(pVnode->pBufPool->incycle), pVMA);
vmaDestroy(pVMA);
}
while (true) {
SVMemAllocator *pVMA = tlistPopHead(&(pVnode->pBufPool->free));
SVMemAllocator *pVMA = tlistHead(&(pVnode->pBufPool->free));
if (pVMA == NULL) break;
tlistPop(&(pVnode->pBufPool->free), pVMA);
vmaDestroy(pVMA);
}
......@@ -83,8 +85,9 @@ void *vnodeMalloc(SVnode *pVnode, uint64_t size) {
if (pBufPool->inuse == NULL) {
while (true) {
// TODO: add sem_wait and sem_post
pBufPool->inuse = tlistPopHead(&(pBufPool->free));
pBufPool->inuse = tlistHead(&(pBufPool->free));
if (pBufPool->inuse) {
tlistPop(&(pBufPool->free), pBufPool->inuse);
break;
}
}
......
......@@ -131,7 +131,7 @@ TEST(vnodeApiTest, vnodeOpen_vnodeClose_test) {
{
// Create some child tables
int ntables = 1000000;
int ntables = 1000;
int batch = 10;
for (int i = 0; i < ntables / batch; i++) {
SArray *pMsgs = (SArray *)taosArrayInit(batch, sizeof(SRpcMsg *));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册