Make the thread queue walk function take a cookie to the callback
and implement a _clear() function to clear out the queue
This commit is contained in:
@@ -44,7 +44,7 @@ struct uc_threadmsg{
|
||||
/**
|
||||
* Callback function for the walk and destroy functions.
|
||||
*/
|
||||
typedef void (*uc_thread_queue_walk_func) (struct uc_threadmsg *msg);
|
||||
typedef void (*uc_thread_queue_walk_func) (struct uc_threadmsg *msg, void *cookie);
|
||||
|
||||
|
||||
/**
|
||||
@@ -240,23 +240,40 @@ long uc_thread_queue_length( struct uc_threadqueue *queue );
|
||||
* @param queue Pointer to the queue that should be cleaned
|
||||
* @param free_func pointer to function that will be called for each item.
|
||||
* The function must not in anyway interact with the queue.
|
||||
* @param cookie pointer passed back to the uc_thread_queue_walk_func
|
||||
* @return 0 on success EINVAL if queue is NULL EBUSY if someone is holding any locks on the queue
|
||||
*/
|
||||
int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func);
|
||||
int uc_thread_queue_destroy(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func, void *cookie);
|
||||
|
||||
/**
|
||||
* Walk the elements of the queue, intended for debugging
|
||||
*
|
||||
* The supplied function will be called for each item in the queue, internal queue
|
||||
* locks are held while the function is called, so the supplied function must not
|
||||
* interact with the queue, else deadlock occors.
|
||||
* interact with the queue, else deadlock occurs.
|
||||
*
|
||||
* @param queue Pointer to the queue to walk
|
||||
* @param free_func pointer to function that will be called for each item.
|
||||
* @param cookie pointer passed back to the uc_thread_queue_walk_func
|
||||
* The function must not in anyway interact with the queue.
|
||||
* @return 0 on success
|
||||
*/
|
||||
int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func walk_func);
|
||||
int uc_thread_queue_walk(struct uc_threadqueue *queue, uc_thread_queue_walk_func walk_func, void *cookie);
|
||||
|
||||
|
||||
/**
|
||||
* Clear the queue.
|
||||
* The free_func unless NULL, will be called for each element
|
||||
* locks are held while the function is called, so the supplied function must not
|
||||
* interact with the queue, else deadlock occurs.
|
||||
*
|
||||
* @param queue Pointer to the queue to clear
|
||||
* @param free_func pointer to function that will be called for each item, intended to e.g. release memory
|
||||
* @param cookie pointer passed back to the uc_thread_queue_walk_func
|
||||
* @return 0 on success
|
||||
*/
|
||||
int uc_thread_queue_clear(struct uc_threadqueue *queue, uc_thread_queue_walk_func free_func, void *cookie);
|
||||
|
||||
|
||||
/**
|
||||
* @}*/
|
||||
|
||||
Reference in New Issue
Block a user