agoo_conloop_create(agooErr err, int id) {
     agooConLoop	loop;

    if (NULL == (loop = (agooConLoop)AGOO_MALLOC(sizeof(struct _agooConLoop)))) {
	AGOO_ERR_MEM(err, "connection thread");
    } else {
	int	stat;

	loop->next = NULL;
	if (AGOO_ERR_OK != agoo_queue_multi_init(err, &loop->pub_queue, 256, true, false)) {
	    AGOO_FREE(loop);
	    return NULL;
	}
	loop->id = id;
	loop->res_head = NULL;
	loop->res_tail = NULL;
	if (0 != pthread_mutex_init(&loop->lock, 0)) {
	    AGOO_FREE(loop);
	    agoo_err_no(err, "Failed to initialize loop mutex.");
	    return NULL;
	}
	if (0 != (stat = pthread_create(&loop->thread, NULL, agoo_con_loop, loop))) {
	    agoo_err_set(err, stat, "Failed to create connection loop. %s", strerror(stat));
	    return NULL;
	}
    }
    return loop;
}
agoo_conloop_create(agooErr err, int id) {
     agooConLoop	loop;

    if (NULL == (loop = (agooConLoop)AGOO_MALLOC(sizeof(struct _agooConLoop)))) {
	AGOO_ERR_MEM(err, "connection thread");
    } else {
	int	stat;

	loop->next = NULL;
	if (AGOO_ERR_OK != agoo_queue_multi_init(err, &loop->pub_queue, 256, true, false)) {
	    AGOO_FREE(loop);
	    return NULL;
	}
	loop->id = id;
	loop->res_head = NULL;
	loop->res_tail = NULL;
	if (0 != pthread_mutex_init(&loop->lock, 0)) {
	    AGOO_FREE(loop);
	    agoo_err_no(err, "Failed to initialize loop mutex.");
	    return NULL;
	}
	if (0 != (stat = pthread_create(&loop->thread, NULL, agoo_con_loop, loop))) {
	    agoo_err_set(err, stat, "Failed to create connection loop. %s", strerror(stat));
	    return NULL;
	}
    }
    return loop;
}