GFC Logo GFC Title Logo
Reference Manual
Main Page  |  Namespace List  |  Alphabetical List  |  Class List  |  File List

threadpool.hh

Go to the documentation of this file.
00001 /* GFC-Core: GTK+ Foundation Classes (Core Library) 00002 * Copyright (C) 2003-2004 The GFC 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 GFC_G_THREADPOOL_HH 00025 #define GFC_G_THREADPOOL_HH 00026 00027 #ifndef GFC_OBJECT_HH 00028 #include <gfc/object.hh> 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 GFC { 00040 00041 namespace G { 00042 00043 class Error; 00044 class ThreadTask; 00045 00071 00072 class ThreadPool : public GFC::Object 00073 { 00074 ThreadPool(const ThreadPool&); 00075 ThreadPool& operator=(const ThreadPool&); 00076 00077 typedef std::vector<ThreadTask*> TaskList; 00078 TaskList task_list_; 00079 00080 GThreadPool *pool_; 00081 00082 public: 00083 typedef sigc::slot<void> TaskSlot; 00090 00093 00094 ThreadPool(int max_threads = -1, bool exclusive = false, G::Error *error = 0); 00116 00117 ~ThreadPool(); 00121 00125 00126 GThreadPool* g_thread_pool() const; 00128 00129 operator GThreadPool* () const; 00131 00132 int get_max_threads() const; 00135 00136 unsigned int get_num_threads() const; 00139 00140 unsigned int unprocessed() const; 00143 00147 00148 void push(const TaskSlot& slot, G::Error *error = 0); 00163 00164 void set_max_threads(int max_threads, G::Error *error = 0); 00180 00181 void free(bool immediate = false, bool wait = true); 00205 00207 00208 static unsigned int get_num_unused_threads(); 00211 00212 static int get_max_unused_threads(); 00215 00216 static void set_max_unused_threads(int max_threads); 00221 00222 static void stop_unused_threads(); 00226 }; 00227 00228 } // namespace G 00229 00230 } // namespace GFC 00231 00232 #include <gfc/glib/inline/threadpool.inl> 00233 00234 #endif // GFC_G_THREADPOOL_HH 00235

Generated on Tue Aug 24 00:04:56 2004 for GFC-Core by doxygen 1.3.8