+static void exit_work_queues(void)
+{
+ std::map<unsigned long, os::WorkQueue *>::iterator it;
+
+ it = thread_wq_map.begin();
+ while (it != thread_wq_map.end()) {
+ os::WorkQueue *thread_wq = it->second;
+
+ thread_wq->queue_work(new FlushGLWork);
+ thread_wq->flush();
+ thread_wq->destroy();
+ thread_wq_map.erase(it++);
+ }
+}
+
+static void do_all_calls(void)
+{
+ trace::Call *call;
+ int prev_thread_id = -1;
+ os::WorkQueue *thread_wq = NULL;
+
+ while ((call = parser.parse_call())) {
+ RenderWork *render_work = new RenderWork(call);
+
+ if (use_threads) {
+ if (prev_thread_id != call->thread_id) {
+ if (thread_wq)
+ thread_wq->flush();
+ thread_wq = get_work_queue(call->thread_id);
+ prev_thread_id = call->thread_id;
+ }
+
+ thread_wq->queue_work(render_work);
+ } else {
+ render_work->run();
+ delete render_work;