OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [binutils-2.20.1/] [gold/] [workqueue-internal.h] - Blame information for rev 258

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 205 julius
// workqueue-internal.h -- internal work queue header for gold   -*- C++ -*-
2
 
3
// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
4
// Written by Ian Lance Taylor <iant@google.com>.
5
 
6
// This file is part of gold.
7
 
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.
12
 
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.
17
 
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.
22
 
23
#ifndef GOLD_WORKQUEUE_INTERNAL_H
24
#define GOLD_WORKQUEUE_INTERNAL_H
25
 
26
#include <queue>
27
#include <csignal>
28
 
29
#include "gold-threads.h"
30
#include "workqueue.h"
31
 
32
// This is an internal header file for different gold workqueue
33
// implementations.
34
 
35
namespace gold
36
{
37
 
38
class Workqueue_thread;
39
 
40
// The Workqueue_threader abstract class.  This is the interface used
41
// by the general workqueue code to manage threads.
42
 
43
class Workqueue_threader
44
{
45
 public:
46
  Workqueue_threader(Workqueue* workqueue)
47
    : workqueue_(workqueue)
48
  { }
49
  virtual ~Workqueue_threader()
50
  { }
51
 
52
  // Set the number of threads to use.  This is ignored when not using
53
  // threads.
54
  virtual void
55
  set_thread_count(int) = 0;
56
 
57
  // Return whether to cancel the current thread.
58
  virtual bool
59
  should_cancel_thread() = 0;
60
 
61
 protected:
62
  // Get the Workqueue.
63
  Workqueue*
64
  get_workqueue()
65
  { return this->workqueue_; }
66
 
67
 private:
68
  // The Workqueue.
69
  Workqueue* workqueue_;
70
};
71
 
72
// The threaded instantiation of Workqueue_threader.
73
 
74
class Workqueue_threader_threadpool : public Workqueue_threader
75
{
76
 public:
77
  Workqueue_threader_threadpool(Workqueue*);
78
 
79
  ~Workqueue_threader_threadpool();
80
 
81
  // Set the thread count.
82
  void
83
  set_thread_count(int);
84
 
85
  // Return whether to cancel a thread.
86
  bool
87
  should_cancel_thread();
88
 
89
  // Process all tasks.  This keeps running until told to cancel.
90
  void
91
  process(int thread_number)
92
  { this->get_workqueue()->process(thread_number); }
93
 
94
 private:
95
  // This is set if we need to check the thread count.
96
  volatile sig_atomic_t check_thread_count_;
97
 
98
  // Lock for the remaining members.
99
  Lock lock_;
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.
104
  int threads_;
105
};
106
 
107
} // End namespace gold.
108
 
109
#endif // !defined(GOLD_WORKQUEUE_INTERNAL_H)

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.