Exemplo n.º 1
0
Arquivo: cproc.c Projeto: okayman/ebgn
EC_BOOL cproc_isend_on_item(CPROC *cproc, CPROC_ITEM *cproc_item)
{
    CLIST *sending_queue;
    TASK_NODE *task_node;

    sending_queue = CPROC_ITEM_SENDING_QUEUE(cproc_item);
    while(NULL_PTR != (task_node = (TASK_NODE *)clist_first_data(sending_queue)))
    {
        TASK_BRD_DEFAULT_ACTIVE_COUNTER_INC(LOC_CPROC_0005);

        //task_node_dbg(LOGSTDOUT, "cproc isend node:", task_node);
        cproc_send(cproc, cproc_item, TASK_NODE_BUFF(task_node), TASK_NODE_BUFF_LEN(task_node), &(TASK_NODE_BUFF_POS(task_node)));
        if(TASK_NODE_BUFF_POS(task_node) == TASK_NODE_BUFF_LEN(task_node))
        {
            clist_pop_front(sending_queue);
            TASK_NODE_COMP(task_node) = TASK_WAS_SENT;
        }
        else
        {
            break;
        }
    }

    return (EC_TRUE);
}
Exemplo n.º 2
0
void test_clist(void)
{
    /* CU_ASSERT(NULL == ex_path_normalize(NULL)); */
    int i = 0;
    int test_cnt = 10000;
    clist *list = clist_new();

    CU_ASSERT(0 == clist_len(list));
    for(i = 0; i < test_cnt; ++i) {
        clist_append(list, cobj_int_new(i));
    }

    CU_ASSERT(test_cnt == clist_len(list));
    CU_ASSERT(false == clist_is_empty(list));
    CU_ASSERT(0 == cobj_int_val(clist_at_obj(list, 0)));
    CU_ASSERT(1 == cobj_int_val(clist_at_obj(list, 1)));
    CU_ASSERT(test_cnt - 1 == cobj_int_val(clist_at_obj(list, test_cnt - 1)));

    for(i = 0; i < test_cnt; ++i) {
        void *obj = clist_pop_front(list);
        CU_ASSERT(i == cobj_int_val(obj));
        cobj_free(obj);
    }
    CU_ASSERT(0 == clist_len(list));
    CU_ASSERT(true == clist_is_empty(list));

    for(i = 0; i < test_cnt; ++i) {
        clist_append(list, cobj_int_new(i));
    }
    clist_clear(list);
    CU_ASSERT(0 == clist_len(list));
    for(i = 0; i < test_cnt; ++i) {
        clist_append(list, cobj_int_new(i));
    }

    clist_node *node = NULL;
    void *obj = NULL;
    i = 0;
    clist_foreach_val(list, node, obj) {
        CU_ASSERT(i == cobj_int_val(obj));
        ++i;
    }