static void qlist_move_all(struct qlist_head *from, struct qlist_head *to) { if (unlikely(qlist_empty(from))) return; if (qlist_empty(to)) { *to = *from; qlist_init(from); return; } to->tail->next = from->head; to->tail = from->tail; to->bytes += from->bytes; qlist_init(from); }
static void qlist_free_all(struct qlist_head *q, struct kmem_cache *cache) { struct qlist_node *qlink; if (unlikely(qlist_empty(q))) return; qlink = q->head; while (qlink) { struct kmem_cache *obj_cache = cache ? cache : qlink_to_cache(qlink); struct qlist_node *next = qlink->next; qlink_free(qlink, obj_cache); qlink = next; } qlist_init(q); }
int main (int argc, char *argv[]) { //curl_global_init(CURL_GLOBAL_ALL); //"http://www.winrar.com.cn/download/winrar-x64-521sc.exe" static unsigned int params_initvalue = 0; TrendMessageList = (QueueList *)malloc(sizeof(QueueList)); qlist_init(TrendMessageList); pthread_t pthid_TS,pthid_TG; int ret = pthread_create(&pthid_TS, NULL, Trends_StateEngine, NULL); ret = pthread_create(&pthid_TG, NULL, Trends_GuiEngine, NULL); char cmd[80]; while(1) { TRENDS_Message_t *pmsg = (TRENDS_Message_t *)malloc(sizeof(TRENDS_Message_t)); pmsg->m_msgtype = TRENDS_INPUT_MSG; pmsg->m_keyvalue = TRENDS_KEY_UNDEFINED; scanf("%s",cmd); if(strcmp(cmd,"up")==0) { pmsg->m_keyvalue = TRENDS_KEY_UP; pmsg->m_params = ++params_initvalue; qlist_in(TrendMessageList,pmsg); } else if(strcmp(cmd,"down")==0) { pmsg->m_keyvalue = TRENDS_KEY_DOWN; pmsg->m_params = ++params_initvalue; qlist_in(TrendMessageList,pmsg); } else { break; } } return 0; }
static void qlist_move_cache(struct qlist_head *from, struct qlist_head *to, struct kmem_cache *cache) { struct qlist_node *curr; if (unlikely(qlist_empty(from))) return; curr = from->head; qlist_init(from); while (curr) { struct qlist_node *next = curr->next; struct kmem_cache *obj_cache = qlink_to_cache(curr); if (obj_cache == cache) qlist_put(to, curr, obj_cache->size); else qlist_put(from, curr, obj_cache->size); curr = next; } }