/* This function will initialize the data queue. Calling this function will initialize the data queue control block and set the notification callback function.  */
rt_err_t rt_data_queue_init(struct rt_data_queue *queue, rt_uint16_t size, rt_uint16_t lwm, void(*evt_notify)(struct rt_data_queue *queue, rt_uint32_t event))
/* This function will initialize the data queue. Calling this function will initialize the data queue control block and set the notification callback function.  */
rt_err_t rt_data_queue_init(struct rt_data_queue *queue, rt_uint16_t size, rt_uint16_t lwm, void(*evt_notify)(struct rt_data_queue *queue, rt_uint32_t event))
{
    RT_ASSERT(queue != RT_NULL);
    RT_ASSERT(size > 0);
    queue->evt_notify = evt_notify;
    queue->magic = DATAQUEUE_MAGIC;
    queue->size = size;
    queue->lwm = lwm;
    queue->get_index = 0;
    queue->put_index = 0;
    queue->is_empty = 1;
    queue->is_full = 0;
    rt_spin_lock_init(&(queue->spinlock));
    rt_list_init(&(queue->suspended_push_list));
    rt_list_init(&(queue->suspended_pop_list));
    queue->queue = (struct rt_data_item *)rt_malloc(sizeof(struct rt_data_item) * size);
    if (queue->queue == RT_NULL)
    {
        return -RT_ENOMEM;
    }
    return RT_EOK;
}