aboutsummaryrefslogtreecommitdiff
path: root/gold/workqueue.cc
diff options
context:
space:
mode:
authorIan Lance Taylor <iant@google.com>2008-02-28 19:46:06 +0000
committerIan Lance Taylor <iant@google.com>2008-02-28 19:46:06 +0000
commitda769d5629564b82d4eec1b256ffc562d5c01624 (patch)
treec575a166927823074cd07dad6347b0e90072340f /gold/workqueue.cc
parenta7dfd0102bbf259cad78b322915523adb366837a (diff)
downloadgdb-da769d5629564b82d4eec1b256ffc562d5c01624.zip
gdb-da769d5629564b82d4eec1b256ffc562d5c01624.tar.gz
gdb-da769d5629564b82d4eec1b256ffc562d5c01624.tar.bz2
Read input scripts which look like input objects with proper
serialization.
Diffstat (limited to 'gold/workqueue.cc')
-rw-r--r--gold/workqueue.cc47
1 files changed, 40 insertions, 7 deletions
diff --git a/gold/workqueue.cc b/gold/workqueue.cc
index 647daf2..68d716e 100644
--- a/gold/workqueue.cc
+++ b/gold/workqueue.cc
@@ -50,6 +50,24 @@ Task_list::push_back(Task* t)
}
}
+// Add T to the front of the list.
+
+inline void
+Task_list::push_front(Task* t)
+{
+ gold_assert(t->list_next() == NULL);
+ if (this->head_ == NULL)
+ {
+ this->head_ = t;
+ this->tail_ = t;
+ }
+ else
+ {
+ t->set_list_next(this->head_);
+ this->head_ = t;
+ }
+}
+
// Remove and return the first Task waiting for this lock to be
// released.
@@ -130,19 +148,25 @@ Workqueue::~Workqueue()
// waiting for a Token.
void
-Workqueue::add_to_queue(Task_list* queue, Task* t)
+Workqueue::add_to_queue(Task_list* queue, Task* t, bool front)
{
Hold_lock hl(this->lock_);
Task_token* token = t->is_runnable();
if (token != NULL)
{
- token->add_waiting(t);
+ if (front)
+ token->add_waiting_front(t);
+ else
+ token->add_waiting(t);
++this->waiting_;
}
else
{
- queue->push_back(t);
+ if (front)
+ queue->push_front(t);
+ else
+ queue->push_back(t);
// Tell any waiting thread that there is work to do.
this->condvar_.signal();
}
@@ -153,16 +177,25 @@ Workqueue::add_to_queue(Task_list* queue, Task* t)
void
Workqueue::queue(Task* t)
{
- this->add_to_queue(&this->tasks_, t);
+ this->add_to_queue(&this->tasks_, t, false);
+}
+
+// Queue a task which should run soon.
+
+void
+Workqueue::queue_soon(Task* t)
+{
+ t->set_should_run_soon();
+ this->add_to_queue(&this->first_tasks_, t, false);
}
-// Add a task to the front of the queue.
+// Queue a task which should run next.
void
-Workqueue::queue_front(Task* t)
+Workqueue::queue_next(Task* t)
{
t->set_should_run_soon();
- this->add_to_queue(&this->first_tasks_, t);
+ this->add_to_queue(&this->first_tasks_, t, true);
}
// Return whether to cancel the current thread.