MCPcopy Create free account
hub / github.com/RT-Thread/rt-thread / rt_workqueue_create

Function rt_workqueue_create

components/drivers/ipc/workqueue.c:217–245  ·  view source on GitHub ↗

* @brief Create a work queue with a thread inside. * * @param name is a name of the work queue thread. * * @param stack_size is stack size of the work queue thread. * * @param priority is a priority of the work queue thread. * * @return Return a pointer to the workqueue object. It will return RT_NULL if failed. */

Source from the content-addressed store, hash-verified

215 * @return Return a pointer to the workqueue object. It will return RT_NULL if failed.
216 */
217struct rt_workqueue *rt_workqueue_create(const char *name, rt_uint16_t stack_size, rt_uint8_t priority)
218{
219 struct rt_workqueue *queue = RT_NULL;
220
221 queue = (struct rt_workqueue *)RT_KERNEL_MALLOC(sizeof(struct rt_workqueue));
222 if (queue != RT_NULL)
223 {
224 /* initialize work list */
225 rt_list_init(&(queue->work_list));
226 rt_list_init(&(queue->delayed_list));
227 queue->work_current = RT_NULL;
228 rt_sem_init(&(queue->sem), "wqueue", 0, RT_IPC_FLAG_FIFO);
229 rt_completion_init(&(queue->wakeup_completion));
230
231 /* create the work thread */
232 queue->work_thread = rt_thread_create(name, _workqueue_thread_entry, queue, stack_size, priority, 10);
233 if (queue->work_thread == RT_NULL)
234 {
235 rt_sem_detach(&(queue->sem));
236 RT_KERNEL_FREE(queue);
237 return RT_NULL;
238 }
239
240 rt_spin_lock_init(&(queue->spinlock));
241 rt_thread_startup(queue->work_thread);
242 }
243
244 return queue;
245}
246
247/**
248 * @brief Destroy a work queue.

Callers 15

rt_bypass_lower_registerFunction · 0.85
_tty_workqueue_initFunction · 0.85
rt_sdhci_init_hostFunction · 0.85
rt_wlan_workqueue_initFunction · 0.85
do_work_testFunction · 0.85
do_delay_work_testFunction · 0.85
cancle_work_test01Function · 0.85
cancle_work_test02Function · 0.85
cancle_work_test03Function · 0.85
cancle_work_test04Function · 0.85
cancle_delay_work_test01Function · 0.85

Calls 7

rt_list_initFunction · 0.85
rt_sem_initFunction · 0.85
rt_thread_createFunction · 0.85
rt_sem_detachFunction · 0.85
rt_thread_startupFunction · 0.85
rt_completion_initFunction · 0.70
rt_spin_lock_initFunction · 0.50

Tested by

no test coverage detected