[Mesa-dev] [PATCH v2 3/8] u_queue: group fence functions together

Nicolai Hähnle nhaehnle at gmail.com
Fri Nov 3 20:09:12 UTC 2017


From: Nicolai Hähnle <nicolai.haehnle at amd.com>

Reviewed-by: Marek Olšák <marek.olsak at amd.com>
---
 src/util/u_queue.h | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/src/util/u_queue.h b/src/util/u_queue.h
index ff713ae54d6..7a028ef0847 100644
--- a/src/util/u_queue.h
+++ b/src/util/u_queue.h
@@ -47,20 +47,30 @@ extern "C" {
 
 /* Job completion fence.
  * Put this into your job structure.
  */
 struct util_queue_fence {
    mtx_t mutex;
    cnd_t cond;
    int signalled;
 };
 
+void util_queue_fence_init(struct util_queue_fence *fence);
+void util_queue_fence_destroy(struct util_queue_fence *fence);
+void util_queue_fence_wait(struct util_queue_fence *fence);
+
+static inline bool
+util_queue_fence_is_signalled(struct util_queue_fence *fence)
+{
+   return fence->signalled != 0;
+}
+
 typedef void (*util_queue_execute_func)(void *job, int thread_index);
 
 struct util_queue_job {
    void *job;
    struct util_queue_fence *fence;
    util_queue_execute_func execute;
    util_queue_execute_func cleanup;
 };
 
 /* Put this into your context. */
@@ -81,49 +91,40 @@ struct util_queue {
    /* for cleanup at exit(), protected by exit_mutex */
    struct list_head head;
 };
 
 bool util_queue_init(struct util_queue *queue,
                      const char *name,
                      unsigned max_jobs,
                      unsigned num_threads,
                      unsigned flags);
 void util_queue_destroy(struct util_queue *queue);
-void util_queue_fence_init(struct util_queue_fence *fence);
-void util_queue_fence_destroy(struct util_queue_fence *fence);
 
 /* optional cleanup callback is called after fence is signaled: */
 void util_queue_add_job(struct util_queue *queue,
                         void *job,
                         struct util_queue_fence *fence,
                         util_queue_execute_func execute,
                         util_queue_execute_func cleanup);
 void util_queue_drop_job(struct util_queue *queue,
                          struct util_queue_fence *fence);
 
-void util_queue_fence_wait(struct util_queue_fence *fence);
 int64_t util_queue_get_thread_time_nano(struct util_queue *queue,
                                         unsigned thread_index);
 
 /* util_queue needs to be cleared to zeroes for this to work */
 static inline bool
 util_queue_is_initialized(struct util_queue *queue)
 {
    return queue->threads != NULL;
 }
 
-static inline bool
-util_queue_fence_is_signalled(struct util_queue_fence *fence)
-{
-   return fence->signalled != 0;
-}
-
 /* Convenient structure for monitoring the queue externally and passing
  * the structure between Mesa components. The queue doesn't use it directly.
  */
 struct util_queue_monitoring
 {
    /* For querying the thread busyness. */
    struct util_queue *queue;
 
    /* Counters updated by the user of the queue. */
    unsigned num_offloaded_items;
-- 
2.11.0



More information about the mesa-dev mailing list