|
Data Structures | |
| struct | workqueue_task |
| Task to be run from a work queue. More... | |
| struct | workqueue |
| Work queue. More... | |
| struct | nested_workqueue |
| Nested Work Queue. More... | |
Typedefs | |
| typedef void(* | workqueue_func_t )(struct workqueue_task *task) |
| Work queue worker function. | |
Functions | |
| bool | workqueue_add_task (struct workqueue *queue, struct workqueue_task *task) |
| Add task to work queue. | |
| static void | workqueue_init (struct workqueue *queue) |
| Initialize a work queue. | |
| static void | workqueue_task_set_work_func (struct workqueue_task *task, workqueue_func_t worker_func) |
| Change the worker function of a task. | |
| static void | workqueue_task_init (struct workqueue_task *task, workqueue_func_t worker_func) |
| Initialize a work queue task. | |
| static bool | workqueue_is_empty (struct workqueue *queue) |
| Check if a work queue is empty. | |
| static bool | workqueue_task_is_queued (struct workqueue_task *task) |
| Check if a work queue task has been queued. | |
| static struct workqueue_task * | workqueue_pop_task (struct workqueue *queue) |
| Remove task from front of work queue. | |
| static void | workqueue_run_task (struct workqueue_task *task) |
| Run a work queue task. | |
Variables | |
| struct workqueue | main_workqueue |
| The main work queue. | |
| struct workqueue | main_workqueue |
| The main work queue. | |
Nested Workqueues | |
Nested workqueues are workqueues specific to certain shared resources, for example a bus driver which can only handle one request at a time. Such drivers may create a workqueue for keeping track of tasks wanting to use the shared resource, and move them one by one into the main workqueue. | |
| bool | nested_workqueue_add_task (struct nested_workqueue *nwq, struct workqueue_task *task) |
| Add task to nested work queue. | |
| void | nested_workqueue_next_task (struct nested_workqueue *nwq) |
| Switch to the next task in a nested work queue. | |
| static void | nested_workqueue_init (struct nested_workqueue *wq) |
| Initialize a nested workqueue. | |
This is a workqueue designed to simplify and formalize sequential execution of tasks. It provides a low overhead structure that can replace or extend the use of threads in simple applications.
| typedef void(* workqueue_func_t)(struct workqueue_task *task) |
Work queue worker function.
| task | The work queue task which is currently being executed |
Definition at line 63 of file workqueue.h.
| bool nested_workqueue_add_task | ( | struct nested_workqueue * | nwq, | |
| struct workqueue_task * | task | |||
| ) |
Add task to nested work queue.
This adds task to the nested work queue nwq. If there is no task currently active, i.e. nwq->current is NULL, the new task is immediately made active by moving it to the main workqueue and assigning it to nwq->current.
| nwq | A nested workqueue | |
| task | Task to be added to the nested work queue |
| true | The task was successfully queued | |
| false | The task has already been queued, so nothing was done |
Referenced by spi_request_bus().
| static void nested_workqueue_init | ( | struct nested_workqueue * | wq | ) | [inline, static] |
Initialize a nested workqueue.
| wq | Nested workqueue to inititalize |
Definition at line 255 of file workqueue.h.
References nested_workqueue::current, workqueue_init(), and nested_workqueue::wq.
| void nested_workqueue_next_task | ( | struct nested_workqueue * | nwq | ) |
Switch to the next task in a nested work queue.
This removes the task at the head of the nested work queue nwq, if any, and makes it current by adding it to the main workqueue and assigning it to nwq->current. If nwq is empty, nwq->current is set to NULL.
| nwq | A nested workqueue |
Referenced by spi_release_bus().
| bool workqueue_add_task | ( | struct workqueue * | queue, | |
| struct workqueue_task * | task | |||
| ) |
Add task to work queue.
This function adds a task to a work queue. The task structure must be initialized by the caller, and only a pointer to it is stored in the queue. The caller must make sure the task struct is kept intact while in the queue and if necessary freed after running the task. The task is removed from the queue before the worker function is called, so it is safe to free or re-queue the task from the worker function.
If task has already been added to some work queue, or task is NULL, this function does nothing.
| queue | Work queue | |
| task | Task to be added to queue |
| true | The task was successfully queued | |
| false | The task has already been queued, or is NULL, so nothing was done |
Referenced by app_dataflash_ready(), app_usb_mode_worker(), at90usb_ep_interrupt(), at90usb_generic_interrupt(), at90usb_udc_submit_in_queue(), dataflash_detect(), dataflash_submit_buf_list(), spi_poll(), spi_polled_sched_next_buffer(), and spi_polled_sched_poll().
| static void workqueue_init | ( | struct workqueue * | queue | ) | [inline, static] |
Initialize a work queue.
| queue | The work queue to be initialized |
Definition at line 109 of file workqueue.h.
References assert, slist_init(), and workqueue::task_list.
Referenced by main(), and nested_workqueue_init().
| static bool workqueue_is_empty | ( | struct workqueue * | queue | ) | [inline, static] |
Check if a work queue is empty.
| queue | Work queue |
Definition at line 161 of file workqueue.h.
References assert, slist_is_empty(), and workqueue::task_list.
Referenced by workqueue_pop_task().
| static struct workqueue_task* workqueue_pop_task | ( | struct workqueue * | queue | ) | [static, read] |
Remove task from front of work queue.
This function removes one task from the front of a work queue and returns a pointer to that item. The memory allocated to the item struct will not be freed. If the queue is empty, a NULL pointer will be returned.
| queue | Work queue |
Definition at line 198 of file workqueue.h.
References assert, cpu_irq_is_enabled, slist_node::next, workqueue_task::node, slist_pop_head, workqueue::task_list, and workqueue_is_empty().
Referenced by mainloop_run().
| static void workqueue_run_task | ( | struct workqueue_task * | task | ) | [inline, static] |
Run a work queue task.
| task | The work queue task to be run |
Definition at line 222 of file workqueue.h.
References workqueue_task::worker.
Referenced by mainloop_run().
| static void workqueue_task_init | ( | struct workqueue_task * | task, | |
| workqueue_func_t | worker_func | |||
| ) | [inline, static] |
Initialize a work queue task.
This function initialize a work queue task. It should be used before adding the task to any workqueue.
| task | Work queue task to be initialized | |
| worker_func | Function implementing the task |
Definition at line 144 of file workqueue.h.
References slist_node::next, workqueue_task::node, and workqueue_task_set_work_func().
Referenced by at90usb_ep_alloc(), at90usb_udc_init(), dataflash_prepare_req(), main(), and spi_polled_buf_list_init().
| static bool workqueue_task_is_queued | ( | struct workqueue_task * | task | ) | [inline, static] |
Check if a work queue task has been queued.
| true | task has already been added to a workqueue | |
| false | task has not been added to any workqueue |
Definition at line 175 of file workqueue.h.
References slist_node::next, and workqueue_task::node.
| static void workqueue_task_set_work_func | ( | struct workqueue_task * | task, | |
| workqueue_func_t | worker_func | |||
| ) | [inline, static] |
Change the worker function of a task.
It is safe to call this function on tasks that have already been queued.
| task | Task to be updated | |
| worker_func | New worker function for the task |
Definition at line 127 of file workqueue.h.
References workqueue_task::worker.
Referenced by app_dataflash_ready(), main(), and workqueue_task_init().
| struct workqueue main_workqueue |
The main work queue.
This is the main work queue of the application. The main loop will pull tasks from this and execute them one by one. It can be considered a queue of tasks waiting to use the CPU resource; other workqueues will typically contend for some other resource, e.g. a SPI bus or flash device.
Definition at line 47 of file workqueue.c.
Referenced by app_dataflash_ready(), app_usb_mode_worker(), at90usb_ep_interrupt(), at90usb_generic_interrupt(), at90usb_udc_submit_in_queue(), dataflash_detect(), dataflash_submit_buf_list(), main(), spi_poll(), spi_polled_sched_next_buffer(), and spi_polled_sched_poll().
| struct workqueue main_workqueue |
The main work queue.
This is the main work queue of the application. The main loop will pull tasks from this and execute them one by one. It can be considered a queue of tasks waiting to use the CPU resource; other workqueues will typically contend for some other resource, e.g. a SPI bus or flash device.
Definition at line 47 of file workqueue.c.
Referenced by app_dataflash_ready(), app_usb_mode_worker(), at90usb_ep_interrupt(), at90usb_generic_interrupt(), at90usb_udc_submit_in_queue(), dataflash_detect(), dataflash_submit_buf_list(), main(), spi_poll(), spi_polled_sched_next_buffer(), and spi_polled_sched_poll().
1.6.3