void cevents_push_fired(cevents *cevts, cevent_fired *fired) { LOCK(&cevts->qlock); clist_lpush(cevts->events[fired->fd].fired_queue, (void*)fired); int *fd = jmalloc(sizeof(int)); *fd = fired->fd; clist_lpush(cevts->fired_fds, (void*)fd); UNLOCK(&cevts->qlock); }
static void test_clist_lpush(void) { list_node_t *list = &test_clist; test_clist_add_two(); clist_lpush(list, &tests_clist_buf[2]); TEST_ASSERT_NOT_NULL(list->next); TEST_ASSERT(list->next->next == &tests_clist_buf[2]); }
int main(int argc, char const *argv[]) { size_t i; lock = SL_UNLOCK; cl = clist_create(); count = 0; for(i = 0; i < 6; i++) clist_lpush(cl, NULL); clist_rpop(cl); clist_rpop(cl); clist_rpop(cl); clist_rpop(cl); clist_rpop(cl); clist_rpop(cl); for(i = 0; i < 6; i++) clist_lpush(cl, NULL); clist_destroy(cl); cl = clist_create(); for(i = 0; i < 1000; i++) clist_rpush(cl, NULL); for(i = 0; i < 1000; i++) clist_lpush(cl, NULL); for(i = 0; i < 1000; i++) clist_lpop(cl); for(i = 0; i < 1000; i++) clist_rpop(cl); clist_destroy(cl); printf("%llu\n", used_mem()); return 0; }
int main(int argc, char const *argv[]) { int m, i, ret; data data; cthread *thr; data.cq = clist_create(); data.lock = SL_UNLOCK; cthr_pool *pool = cthr_pool_create(10); cthr_pool_destroy(pool); pool = cthr_pool_create(100); for(m = 0; m < 100; m++) { for(i = 0; i < 10; i++){ spinlock_lock(&data.lock); clist_lpush(data.cq, NULL); spinlock_unlock(&data.lock); } cthr_pool_run_task(pool, print_test, &data); } cthr_pool_destroy(pool); for(i = 0; i < pool->size; i++) { thr = pool->thrs + i; printf("%d\n", thr->state); } return 0; }
void cevents_push_fired(cevents *cevts, cevent_fired *fired) { LOCK(&cevts->qlock); clist_lpush(cevts->fired_queue, (void*)fired); UNLOCK(&cevts->qlock); }