// workqueue.cc -- the workqueue for gold
-// Copyright 2006, 2007 Free Software Foundation, Inc.
+// Copyright (C) 2006-2014 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// This file is part of gold.
#include "debug.h"
#include "options.h"
+#include "timer.h"
#include "workqueue.h"
#include "workqueue-internal.h"
{ gold_assert(thread_count > 0); }
bool
- should_cancel_thread()
+ should_cancel_thread(int)
{ return false; }
};
// Return whether to cancel the current thread.
inline bool
-Workqueue::should_cancel_thread()
+Workqueue::should_cancel_thread(int thread_number)
{
- return this->threader_->should_cancel_thread();
+ return this->threader_->should_cancel_thread(thread_number);
}
// Find a runnable task in TASKS. Return NULL if none could be found.
return NULL;
}
- if (this->should_cancel_thread())
+ if (this->should_cancel_thread(thread_number))
return NULL;
gold_debug(DEBUG_TASK, "%3d sleeping", thread_number);
gold_debug(DEBUG_TASK, "%3d running task %s", thread_number,
t->name().c_str());
+ Timer timer;
+ if (is_debugging_enabled(DEBUG_TASK))
+ timer.start();
+
t->run(this);
- gold_debug(DEBUG_TASK, "%3d completed task %s", thread_number,
- t->name().c_str());
+ if (is_debugging_enabled(DEBUG_TASK))
+ {
+ Timer::TimeStats elapsed = timer.get_elapsed_time();
+
+ gold_debug(DEBUG_TASK,
+ "%3d completed task %s "
+ "(user: %ld.%06ld sys: %ld.%06ld wall: %ld.%06ld)",
+ thread_number, t->name().c_str(),
+ elapsed.user / 1000, (elapsed.user % 1000) * 1000,
+ elapsed.sys / 1000, (elapsed.sys % 1000) * 1000,
+ elapsed.wall / 1000, (elapsed.wall % 1000) * 1000);
+ }
Task* next;
{
this->condvar_.broadcast();
}
+// Add a new blocker to an existing Task_token.
+
+void
+Workqueue::add_blocker(Task_token* token)
+{
+ Hold_lock hl(this->lock_);
+ token->add_blocker();
+}
+
} // End namespace gold.