*** empty log message ***
[deliverable/binutils-gdb.git] / gold / workqueue.h
index a97d86d4c6f50550486924d3cd6c6c99fbf9405d..ed7a5b00d7ddf030abe295497a2ef91d2b2170a6 100644 (file)
 #define GOLD_WORKQUEUE_H
 
 #include "gold-threads.h"
-#include "options.h"
 #include "fileread.h"
 
 namespace gold
 {
 
+class General_options;
 class Task;
 class Workqueue;
 
@@ -286,6 +286,62 @@ class Task
   // Run the task.
   virtual void
   run(Workqueue*) = 0;
+
+ private:
+  Task(const Task&);
+  Task& operator=(const Task&);
+};
+
+// A simple task which waits for a blocker and then runs a function.
+
+class Task_function_runner
+{
+ public:
+  virtual ~Task_function_runner()
+  { }
+
+  virtual void
+  run(Workqueue*) = 0;
+};
+
+class Task_function : public Task
+{
+ public:
+  // Both points should be allocated using new, and will be deleted
+  // after the task runs.
+  Task_function(Task_function_runner* runner, Task_token* blocker)
+    : runner_(runner), blocker_(blocker)
+  { }
+
+  ~Task_function()
+  {
+    delete this->runner_;
+    delete this->blocker_;
+  }
+
+  // The standard task methods.
+
+  // Wait until the task is unblocked.
+  Is_runnable_type
+  is_runnable(Workqueue*)
+  { return this->blocker_->is_blocked() ? IS_BLOCKED : IS_RUNNABLE; }
+
+  // This type of task does not normally hold any locks.
+  virtual Task_locker*
+  locks(Workqueue*)
+  { return NULL; }
+
+  // Run the action.
+  void
+  run(Workqueue* workqueue)
+  { this->runner_->run(workqueue); }
+
+ private:
+  Task_function(const Task_function&);
+  Task_function& operator=(const Task_function&);
+
+  Task_function_runner* runner_;
+  Task_token* blocker_;
 };
 
 // The workqueue
@@ -302,6 +358,11 @@ class Workqueue
   void
   queue(Task*);
 
+  // Add a new task to the front of the work queue.  It will be the
+  // next task to run if it is ready.
+  void
+  queue_front(Task*);
+
   // Process all the tasks on the work queue.
   void
   process();
This page took 0.024546 seconds and 4 git commands to generate.