#include <types.h>
#include <slist.h>
#include <util.h>
#include <interrupt.h>


Go to the source code of this file.
Data Structures | |
| struct | workqueue_item |
| struct | workqueue |
Typedefs | |
| typedef void(* | workqueue_callback_t )(void *data) |
Functions | |
| static void | workqueue_init (struct workqueue *queue) |
| Initialize a new work queue. | |
| static void | workqueue_init_item (struct workqueue_item *item, workqueue_callback_t callback, void *data) |
| Initialize a work item. | |
| static bool | workqueue_is_empty (struct workqueue *queue) |
| Checks if the queue is empty or not. | |
| static bool | workqueue_item_is_queued (struct workqueue_item *item) |
| Checks if item has already been queued. | |
| static void | workqueue_add_item (struct workqueue *queue, struct workqueue_item *item) |
| Add work item to work queue. | |
| static void | workqueue_add_item_safe (struct workqueue *queue, struct workqueue_item *item) |
| Add work item to work queue, unless it has been added before. | |
| static struct workqueue_item * | workqueue_remove_item (struct workqueue *queue) |
| Remove work item from front of queue. | |
| static void | workqueue_move_item (struct workqueue *source, struct workqueue *dest) |
| Move first work item from one queue to the back of another queue. | |
| static void * | workqueue_get_data (struct workqueue_item *item) |
| Get data associated with a workqueue item. | |
| static void | workqueue_do_one_item (struct workqueue *queue) |
| Remove first work item and run its callback. | |
This is a workqueue designed to simplify and formalize sequential execution of work items/fuctions. It provides a low overhead structure that can replace or extend the use of threads in simple applications.
Definition in file workqueue.h.
| typedef void(* workqueue_callback_t)(void *data) |
Work queue callback function pointer type.
Definition at line 54 of file workqueue.h.
| static void workqueue_add_item | ( | struct workqueue * | queue, | |
| struct workqueue_item * | item | |||
| ) | [inline, static] |
Add work item to work queue.
This function adds a work item to a work queue. The item structure must be set up by the caller and only a pointer to it is stored in the queue. The caller must make sure the item struct is kept intact while in the queue and if necessary freed after running the item (This can be done safely in the work item itself). The same item CAN NOT exist twice in the same queue, it can only be added again when the work item has started execution or later.
| queue | Pointer to work queue control structure. | |
| item | Pointer to work item to add. |
Definition at line 155 of file workqueue.h.
References assert, workqueue_item::callback, cpu_irq_restore(), cpu_irq_save(), workqueue::list, slist_node::next, workqueue_item::node, and slist_insert_tail().
Referenced by sdmmc_probe_notify_card_detect(), and workqueue_move_item().

| static void workqueue_add_item_safe | ( | struct workqueue * | queue, | |
| struct workqueue_item * | item | |||
| ) | [inline, static] |
Add work item to work queue, unless it has been added before.
This function adds a work item to a work queue. The item structure must be set up by the caller and only a pointer to it is stored in the queue. The caller must make sure the item struct is kept intact while in the queue and if necessary freed after running the item (This can be done safely in the work item itself).
If item has been queued on any work queue before, this function does nothing.
| queue | Pointer to work queue control structure. | |
| item | Pointer to work item to add. |
Definition at line 191 of file workqueue.h.
References assert, workqueue_item::callback, cpu_irq_restore(), cpu_irq_save(), workqueue::list, workqueue_item::node, slist_insert_tail(), and workqueue_item_is_queued().

| static void workqueue_do_one_item | ( | struct workqueue * | queue | ) | [inline, static] |
Remove first work item and run its callback.
This function removes one work item from the front of the queue and then runs the work callback function. The work item can be considered unused when the callback function is executed and can freely be be reused or freed. If the queue is empty, running this function will not have any effect.
| queue | Pointer to work queue control structure. |
Definition at line 287 of file workqueue.h.
References assert, workqueue_item::callback, workqueue_get_data(), and workqueue_remove_item().

| static void* workqueue_get_data | ( | struct workqueue_item * | item | ) | [inline, static] |
Get data associated with a workqueue item.
| item | Pointer to a workqueue item |
Definition at line 269 of file workqueue.h.
References assert, and workqueue_item::data.
Referenced by workqueue_do_one_item().
| static void workqueue_init | ( | struct workqueue * | queue | ) | [inline, static] |
Initialize a new work queue.
| queue | Pointer to work queue control structure. |
Definition at line 81 of file workqueue.h.
References assert, workqueue::list, and slist_init().

| static void workqueue_init_item | ( | struct workqueue_item * | item, | |
| workqueue_callback_t | callback, | |||
| void * | data | |||
| ) | [inline, static] |
Initialize a work item.
This function initialize a work item. It should be used before adding the item to the workqueue. The caller must make sure memory is allocated for the item struct for initializing. DO NOT initialize a work item already in use (present in a work queue).
| item | Pointer to work item to add. | |
| callback | Pointer to function doing the work | |
| data | Pointer to data that will be passed to the function |
Definition at line 102 of file workqueue.h.
References workqueue_item::callback, workqueue_item::data, slist_node::next, and workqueue_item::node.
Referenced by aesblk_prepare_req(), journal_init(), sdmmc_cd_init(), sdmmc_mcihost_init(), and sdmmc_probe_init().
| static bool workqueue_is_empty | ( | struct workqueue * | queue | ) | [inline, static] |
Checks if the queue is empty or not.
| queue | Pointer to work queue control structure. |
false Queue has at least one item.
Definition at line 122 of file workqueue.h.
References assert, workqueue::list, and slist_is_empty().
Referenced by workqueue_remove_item().

| static bool workqueue_item_is_queued | ( | struct workqueue_item * | item | ) | [inline, static] |
Checks if item has already been queued.
| true | item has already been added to a workqueue | |
| false | item can safely be added to a workqueue |
Definition at line 135 of file workqueue.h.
References slist_node::next, and workqueue_item::node.
Referenced by workqueue_add_item_safe().
| static void workqueue_move_item | ( | struct workqueue * | source, | |
| struct workqueue * | dest | |||
| ) | [inline, static] |
Move first work item from one queue to the back of another queue.
This function removes the first work item from the source queue and adds it to the end of the destination queue.
| source | Pointer to source work queue. | |
| dest | Pointer to destination work queue. |
Definition at line 251 of file workqueue.h.
References assert, workqueue_add_item(), and workqueue_remove_item().

| static struct workqueue_item* workqueue_remove_item | ( | struct workqueue * | queue | ) | [static, read] |
Remove work item from front of queue.
This function removes one work item 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 | Pointer to work queue control structure. |
Definition at line 220 of file workqueue.h.
References assert, cpu_irq_restore(), cpu_irq_save(), workqueue::list, slist_node::next, workqueue_item::node, slist_pop_head, and workqueue_is_empty().
Referenced by workqueue_do_one_item(), and workqueue_move_item().

1.5.8