summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:32:04 +0000
committerJonathan Gray <jsg@cvs.openbsd.org>2016-12-11 08:32:04 +0000
commit2e1d4101e4af144c589469f6b0453471ca769b70 (patch)
tree6c27e9d85c79048c94d870991b8c7de75624e7ad /lib
parentbd87cb4309876f5dd3ad62c53873458243ca26ee (diff)
Import Mesa 13.0.2
Diffstat (limited to 'lib')
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_queue.c79
-rw-r--r--lib/mesa/src/gallium/auxiliary/util/u_queue.h4
2 files changed, 3 insertions, 80 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_queue.c b/lib/mesa/src/gallium/auxiliary/util/u_queue.c
index 643c92b28..838464fb9 100644
--- a/lib/mesa/src/gallium/auxiliary/util/u_queue.c
+++ b/lib/mesa/src/gallium/auxiliary/util/u_queue.c
@@ -29,68 +29,6 @@
#include "u_string.h"
#include "os/os_time.h"
-static void util_queue_killall_and_wait(struct util_queue *queue);
-
-/****************************************************************************
- * Wait for all queues to assert idle when exit() is called.
- *
- * Otherwise, C++ static variable destructors can be called while threads
- * are using the static variables.
- */
-
-static once_flag atexit_once_flag = ONCE_FLAG_INIT;
-static struct list_head queue_list;
-pipe_static_mutex(exit_mutex);
-
-static void
-atexit_handler(void)
-{
- struct util_queue *iter;
-
- pipe_mutex_lock(exit_mutex);
- /* Wait for all queues to assert idle. */
- LIST_FOR_EACH_ENTRY(iter, &queue_list, head) {
- util_queue_killall_and_wait(iter);
- }
- pipe_mutex_unlock(exit_mutex);
-}
-
-static void
-global_init(void)
-{
- LIST_INITHEAD(&queue_list);
- atexit(atexit_handler);
-}
-
-static void
-add_to_atexit_list(struct util_queue *queue)
-{
- call_once(&atexit_once_flag, global_init);
-
- pipe_mutex_lock(exit_mutex);
- LIST_ADD(&queue->head, &queue_list);
- pipe_mutex_unlock(exit_mutex);
-}
-
-static void
-remove_from_atexit_list(struct util_queue *queue)
-{
- struct util_queue *iter, *tmp;
-
- pipe_mutex_lock(exit_mutex);
- LIST_FOR_EACH_ENTRY_SAFE(iter, tmp, &queue_list, head) {
- if (iter == queue) {
- LIST_DEL(&iter->head);
- break;
- }
- }
- pipe_mutex_unlock(exit_mutex);
-}
-
-/****************************************************************************
- * util_queue implementation
- */
-
static void
util_queue_fence_signal(struct util_queue_fence *fence)
{
@@ -166,7 +104,6 @@ static PIPE_THREAD_ROUTINE(util_queue_thread_func, input)
queue->jobs[queue->read_idx].job = NULL;
queue->read_idx = (queue->read_idx + 1) % queue->max_jobs;
}
- queue->num_queued = 0; /* reset this when exiting the thread */
pipe_mutex_unlock(queue->lock);
return 0;
}
@@ -215,13 +152,11 @@ util_queue_init(struct util_queue *queue,
goto fail;
} else {
/* at least one thread created, so use it */
- queue->num_threads = i;
+ queue->num_threads = i+1;
break;
}
}
}
-
- add_to_atexit_list(queue);
return true;
fail:
@@ -238,8 +173,8 @@ fail:
return false;
}
-static void
-util_queue_killall_and_wait(struct util_queue *queue)
+void
+util_queue_destroy(struct util_queue *queue)
{
unsigned i;
@@ -251,14 +186,6 @@ util_queue_killall_and_wait(struct util_queue *queue)
for (i = 0; i < queue->num_threads; i++)
pipe_thread_wait(queue->threads[i]);
- queue->num_threads = 0;
-}
-
-void
-util_queue_destroy(struct util_queue *queue)
-{
- util_queue_killall_and_wait(queue);
- remove_from_atexit_list(queue);
pipe_condvar_destroy(queue->has_space_cond);
pipe_condvar_destroy(queue->has_queued_cond);
diff --git a/lib/mesa/src/gallium/auxiliary/util/u_queue.h b/lib/mesa/src/gallium/auxiliary/util/u_queue.h
index ad3ab6a98..59646cc29 100644
--- a/lib/mesa/src/gallium/auxiliary/util/u_queue.h
+++ b/lib/mesa/src/gallium/auxiliary/util/u_queue.h
@@ -34,7 +34,6 @@
#define U_QUEUE_H
#include "os/os_thread.h"
-#include "util/list.h"
/* Job completion fence.
* Put this into your job structure.
@@ -67,9 +66,6 @@ struct util_queue {
int max_jobs;
int write_idx, read_idx; /* ring buffer pointers */
struct util_queue_job *jobs;
-
- /* for cleanup at exit(), protected by exit_mutex */
- struct list_head head;
};
bool util_queue_init(struct util_queue *queue,