u_queue: add util_queue_fence_reset
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sun, 22 Oct 2017 15:38:30 +0000 (17:38 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Thu, 9 Nov 2017 10:37:39 +0000 (11:37 +0100)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/util/u_queue.c
src/util/u_queue.h

index 33436e0749ad556a4a2f0122dd5c58c3bd4f29b9..2272006042fba3f7aa71a75c27fdc1653e2fb100 100644 (file)
@@ -328,8 +328,6 @@ util_queue_add_job(struct util_queue *queue,
 {
    struct util_queue_job *ptr;
 
-   assert(fence->signalled);
-
    mtx_lock(&queue->lock);
    if (queue->kill_threads) {
       mtx_unlock(&queue->lock);
@@ -339,7 +337,7 @@ util_queue_add_job(struct util_queue *queue,
       return;
    }
 
-   fence->signalled = false;
+   util_queue_fence_reset(fence);
 
    assert(queue->num_queued >= 0 && queue->num_queued <= queue->max_jobs);
 
index 5a546e53fdca89bb8b9a9e3a6f788f40eda8e0b0..a3e12260e302538d4e6839a1bcc2156cb10f227d 100644 (file)
@@ -59,6 +59,19 @@ void util_queue_fence_destroy(struct util_queue_fence *fence);
 void util_queue_fence_wait(struct util_queue_fence *fence);
 void util_queue_fence_signal(struct util_queue_fence *fence);
 
+/**
+ * Move \p fence back into unsignalled state.
+ *
+ * \warning The caller must ensure that no other thread may currently be
+ *          waiting (or about to wait) on the fence.
+ */
+static inline void
+util_queue_fence_reset(struct util_queue_fence *fence)
+{
+   assert(fence->signalled);
+   fence->signalled = 0;
+}
+
 static inline bool
 util_queue_fence_is_signalled(struct util_queue_fence *fence)
 {