Reference Manual
Inti Logo
Main Page | Namespace List | Class Hierarchy | Alphabetical List | Compound List | File List | Namespace Members | Compound Members | File Members

threadpool.h

Go to the documentation of this file.
00001 /*  Inti: Integrated Foundation Classes
00002  *  Copyright (C) 2003 The Inti Development Team.
00003  *
00004  *  This program is free software; you can redistribute it and/or modify
00005  *  it under the terms of the GNU General Public License as published by
00006  *  the Free Software Foundation; either version 2 of the License, or
00007  *  (at your option) any later version.
00008  *
00009  *  This program is distributed in the hope that it will be useful,
00010  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00011  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012  *  GNU Library General Public License for more details.
00013  *
00014  *  You should have received a copy of the GNU Library General Public License
00015  *  along with this program; if not, write to the Free Software
00016  *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017  */
00018 
00023 
00024 #ifndef INTI_G_THREADPOOL_H
00025 #define INTI_G_THREADPOOL_H
00026 
00027 #ifndef INTI_SLOT_H
00028 #include <inti/slot.h>
00029 #endif
00030 
00031 #ifndef __G_THREADPOOL_H__
00032 #include <glib/gthreadpool.h>
00033 #endif
00034 
00035 #ifndef _CPP_VECTOR
00036 #include <vector>
00037 #endif
00038 
00039 namespace Inti {
00040 
00041 namespace G {
00042 
00043 class Error;
00044 
00070 
00071 class ThreadPool : public ReferencedObject
00072 {
00073         ThreadPool(const ThreadPool&);
00074         ThreadPool& operator=(const ThreadPool&);
00075 
00076         GThreadPool *pool_;
00077 
00078 public:
00079         typedef Slot0<void> TaskSlot;
00086 
00087 private:
00088         typedef std::vector<const TaskSlot*> TaskList;
00089         TaskList task_list;
00090 
00091 public:
00094 
00095         ThreadPool(int max_threads = -1, bool exclusive = false, G::Error *error = 0);
00117 
00118         ~ThreadPool();
00122 
00126 
00127         GThreadPool* g_thread_pool() const { return pool_; }
00129 
00130         operator GThreadPool* () const;
00132 
00133         int get_max_threads() const;
00136 
00137         unsigned int get_num_threads() const;
00140 
00141         unsigned int unprocessed() const;
00144 
00148 
00149         void push(const TaskSlot *task, G::Error *error = 0);
00164 
00165         void set_max_threads(int max_threads, G::Error *error = 0);
00181 
00182         void free(bool immediate = false, bool wait = true);
00206 
00208 
00209         static unsigned int get_num_unused_threads();
00212 
00213         static int get_max_unused_threads();
00216 
00217         static void set_max_unused_threads(int max_threads);
00222 
00223         static void stop_unused_threads();
00227 };
00228 
00229 } // namespace G
00230 
00231 } // namespace Inti
00232 
00233 #endif // INTI_G_THREADPOOL_H
00234 
Main Page - Footer


Generated on Sun Sep 14 20:08:04 2003 for Inti by doxygen 1.3.2 written by Dimitri van Heesch, © 1997-2002