Example #1
0
bool workqueue_poll(struct work_queue *wq, bool wait)
{
	T_QUEUE_MESSAGE m;
	OS_ERR_TYPE err;
	if (wq == NULL) {
		pr_error(LOG_MODULE_UTIL,
			 "wq should not be null");
		return 0;
	}
	if (wq->queue == NULL || wq->state == WORKQUEUE_UNINITIALIZED) {
		pr_error(LOG_MODULE_UTIL,
			 "Attempt to poll on uninitialized workqueue");
		return 0;
	}
	queue_get_message(wq->queue, &m,
			  wait ? OS_WAIT_FOREVER : OS_NO_WAIT, &err);
	if (m != NULL) {
		struct wq_elem *w = (struct wq_elem *)m;
		if (w->cb != NULL) {
			w->cb(w->cb_data);
		}
		bfree(w);
	}
	return !(err == E_OS_ERR_EMPTY);
}
Example #2
0
void cfw_process(T_QUEUE queue)
{
    struct cfw_message * message;
    T_QUEUE_MESSAGE m;

    queue_get_message(queue, &m, OS_WAIT_FOREVER, NULL);
    message = (struct cfw_message *) m;
    if ( message != NULL ) {
        pr_info(LOG_MODULE_MAIN, "Got message: %p", message);
		port_process_message(&message->m);
    }
}
void _cfw_loop(void * queue)
{
    struct cfw_message * message;
    T_QUEUE_MESSAGE m;
    while (1) { /* This infinite loop is intentional and requested by design */
        queue_get_message(queue, &m, OS_WAIT_FOREVER, NULL );
        message = (struct cfw_message *) m;
        if (message != NULL ) {
            port_process_message(&message->m);
        }
    }
}
Example #4
0
/**
 * Delete a queue.
 *
 * Free a whole queue.
 * @param queue - The queue to free.
 */
void queue_delete(T_QUEUE queue, OS_ERR_TYPE* err)
{
    OS_ERR_TYPE _err;
    queue_impl_t * q = (queue_impl_t*) queue;
    T_EXEC_LEVEL execLvl = _getExecLevel();
    uint32_t data;
    T_QUEUE_MESSAGE p_msg = &data;

    /* check execution level */
    if ((E_EXEC_LVL_FIBER == execLvl) || (E_EXEC_LVL_TASK == execLvl))
    {
        lock_pool();
        if (queue_used(q) && q->sema != NULL)
        {

            /* first empty the queue before to delete it to free all the elements */
            do{
                queue_get_message(q, &p_msg, OS_NO_WAIT, &_err);
            }while(_err == E_OS_OK);

            if(_err == E_OS_ERR_EMPTY)
            {
                semaphore_delete(q->sema, &_err);
                q->sema = NULL;
                if( _err == E_OS_OK)
                {
                    queue_free(q);
                    error_management (err, E_OS_OK);
                }
                else
                {
                    panic(E_OS_ERR_UNKNOWN);    // Panic because we should never reach this point.
                }
            }
            else
            {
                error_management (err, E_OS_ERR);
            }
        }
        else
        {
            error_management (err, E_OS_ERR);
        }
        unlock_pool();
    }
    else
    {
        error_management (err, E_OS_ERR_NOT_ALLOWED);
    }
    return;
}