1 // workqueue-internal.h -- internal work queue header for gold -*- C++ -*-
3 // Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4 // Written by Ian Lance Taylor <iant@google.com>.
6 // This file is part of gold.
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 3 of the License, or
11 // (at your option) any later version.
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 // GNU General Public License for more details.
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21 // MA 02110-1301, USA.
23 #ifndef GOLD_WORKQUEUE_INTERNAL_H
24 #define GOLD_WORKQUEUE_INTERNAL_H
29 #include "gold-threads.h"
30 #include "workqueue.h"
32 // This is an internal header file for different gold workqueue
38 class Workqueue_thread
;
40 // The Workqueue_threader abstract class. This is the interface used
41 // by the general workqueue code to manage threads.
43 class Workqueue_threader
46 Workqueue_threader(Workqueue
* workqueue
)
47 : workqueue_(workqueue
)
49 virtual ~Workqueue_threader()
52 // Set the number of threads to use. This is ignored when not using
55 set_thread_count(int) = 0;
57 // Return whether to cancel the current thread.
59 should_cancel_thread() = 0;
65 { return this->workqueue_
; }
69 Workqueue
* workqueue_
;
72 // The threaded instantiation of Workqueue_threader.
74 class Workqueue_threader_threadpool
: public Workqueue_threader
77 Workqueue_threader_threadpool(Workqueue
*);
79 ~Workqueue_threader_threadpool();
81 // Set the thread count.
83 set_thread_count(int);
85 // Return whether to cancel a thread.
87 should_cancel_thread();
89 // Process all tasks. This keeps running until told to cancel.
91 process(int thread_number
)
92 { this->get_workqueue()->process(thread_number
); }
95 // This is set if we need to check the thread count.
96 volatile sig_atomic_t check_thread_count_
;
98 // Lock for the remaining members.
100 // The number of threads we want to create. This is set to zero
101 // when all threads should exit.
102 int desired_thread_count_
;
103 // The number of threads currently running.
107 } // End namespace gold.
109 #endif // !defined(GOLD_WORKQUEUE_INTERNAL_H)