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

Subversion Repositories open8_urisc

[/] [open8_urisc/] [trunk/] [gnu/] [binutils/] [gold/] [workqueue-internal.h] - Diff between revs 27 and 159

Go to most recent revision | Only display areas with differences | Details | Blame | View Log

Rev 27 Rev 159
// workqueue-internal.h -- internal work queue header for gold   -*- C++ -*-
// workqueue-internal.h -- internal work queue header for gold   -*- C++ -*-
 
 
// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
// Copyright 2006, 2007, 2008 Free Software Foundation, Inc.
// Written by Ian Lance Taylor <iant@google.com>.
// Written by Ian Lance Taylor <iant@google.com>.
 
 
// This file is part of gold.
// This file is part of gold.
 
 
// This program is free software; you can redistribute it and/or modify
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
// (at your option) any later version.
 
 
// This program is distributed in the hope that it will be useful,
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.
// GNU General Public License for more details.
 
 
// You should have received a copy of the GNU General Public License
// You should have received a copy of the GNU General Public License
// along with this program; if not, write to the Free Software
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
// MA 02110-1301, USA.
// MA 02110-1301, USA.
 
 
#ifndef GOLD_WORKQUEUE_INTERNAL_H
#ifndef GOLD_WORKQUEUE_INTERNAL_H
#define GOLD_WORKQUEUE_INTERNAL_H
#define GOLD_WORKQUEUE_INTERNAL_H
 
 
#include <queue>
#include <queue>
#include <csignal>
#include <csignal>
 
 
#include "gold-threads.h"
#include "gold-threads.h"
#include "workqueue.h"
#include "workqueue.h"
 
 
// This is an internal header file for different gold workqueue
// This is an internal header file for different gold workqueue
// implementations.
// implementations.
 
 
namespace gold
namespace gold
{
{
 
 
class Workqueue_thread;
class Workqueue_thread;
 
 
// The Workqueue_threader abstract class.  This is the interface used
// The Workqueue_threader abstract class.  This is the interface used
// by the general workqueue code to manage threads.
// by the general workqueue code to manage threads.
 
 
class Workqueue_threader
class Workqueue_threader
{
{
 public:
 public:
  Workqueue_threader(Workqueue* workqueue)
  Workqueue_threader(Workqueue* workqueue)
    : workqueue_(workqueue)
    : workqueue_(workqueue)
  { }
  { }
  virtual ~Workqueue_threader()
  virtual ~Workqueue_threader()
  { }
  { }
 
 
  // Set the number of threads to use.  This is ignored when not using
  // Set the number of threads to use.  This is ignored when not using
  // threads.
  // threads.
  virtual void
  virtual void
  set_thread_count(int) = 0;
  set_thread_count(int) = 0;
 
 
  // Return whether to cancel the current thread.
  // Return whether to cancel the current thread.
  virtual bool
  virtual bool
  should_cancel_thread() = 0;
  should_cancel_thread(int thread_number) = 0;
 
 
 protected:
 protected:
  // Get the Workqueue.
  // Get the Workqueue.
  Workqueue*
  Workqueue*
  get_workqueue()
  get_workqueue()
  { return this->workqueue_; }
  { return this->workqueue_; }
 
 
 private:
 private:
  // The Workqueue.
  // The Workqueue.
  Workqueue* workqueue_;
  Workqueue* workqueue_;
};
};
 
 
// The threaded instantiation of Workqueue_threader.
// The threaded instantiation of Workqueue_threader.
 
 
class Workqueue_threader_threadpool : public Workqueue_threader
class Workqueue_threader_threadpool : public Workqueue_threader
{
{
 public:
 public:
  Workqueue_threader_threadpool(Workqueue*);
  Workqueue_threader_threadpool(Workqueue*);
 
 
  ~Workqueue_threader_threadpool();
  ~Workqueue_threader_threadpool();
 
 
  // Set the thread count.
  // Set the thread count.
  void
  void
  set_thread_count(int);
  set_thread_count(int);
 
 
  // Return whether to cancel a thread.
  // Return whether to cancel a thread.
  bool
  bool
  should_cancel_thread();
  should_cancel_thread(int thread_number);
 
 
  // Process all tasks.  This keeps running until told to cancel.
  // Process all tasks.  This keeps running until told to cancel.
  void
  void
  process(int thread_number)
  process(int thread_number)
  { this->get_workqueue()->process(thread_number); }
  { this->get_workqueue()->process(thread_number); }
 
 
 private:
 private:
  // This is set if we need to check the thread count.
  // This is set if we need to check the thread count.
  volatile sig_atomic_t check_thread_count_;
  volatile sig_atomic_t check_thread_count_;
 
 
  // Lock for the remaining members.
  // Lock for the remaining members.
  Lock lock_;
  Lock lock_;
  // The number of threads we want to create.  This is set to zero
  // The number of threads we want to create.  This is set to zero
  // when all threads should exit.
  // when all threads should exit.
  int desired_thread_count_;
  int desired_thread_count_;
  // The number of threads currently running.
  // The number of threads currently running.
  int threads_;
  int threads_;
};
};
 
 
} // End namespace gold.
} // End namespace gold.
 
 
#endif // !defined(GOLD_WORKQUEUE_INTERNAL_H)
#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.