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

more

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