basix_doc 0.1
/Users/mourrain/Devel/mmx/basix/include/basix/threads.hpp
Go to the documentation of this file.
00001 
00002 /******************************************************************************
00003 * MODULE     : threads.hpp
00004 * DESCRIPTION: Multi-threading
00005 * COPYRIGHT  : (C) 2007  Joris van der Hoeven
00006 *******************************************************************************
00007 * This software falls under the GNU general public license and comes WITHOUT
00008 * ANY WARRANTY WHATSOEVER. See the file $TEXMACS_PATH/LICENSE for more details.
00009 * If you don't have this file, write to the Free Software Foundation, Inc.,
00010 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00011 ******************************************************************************/
00012 
00013 #ifndef __MMX_THREADS_HPP
00014 #define __MMX_THREADS_HPP
00015 #include <basix/exception.hpp>
00016 
00017 #ifdef BASIX_ENABLE_THREADS
00018 #include <pthread.h>
00019 #endif
00020 
00022 
00023 namespace mmx {
00024 
00025 /******************************************************************************
00026 * Parallel execution of tasks
00027 ******************************************************************************/
00028 
00029 class task_rep REP_STRUCT {
00030 public:
00031   inline task_rep () {}
00032   virtual ~task_rep () {}
00033   virtual void execute () = 0;
00034 };
00035 
00036 class task {
00037 INDIRECT_PROTO (task, task_rep)
00038 public:
00039   inline task (): rep (NULL) {}
00040 };
00041 INDIRECT_NULL_IMPL (task, task_rep)
00042 
00043 extern nat  threads_number;
00044 void threads_initialize (nat n);
00045 void threads_terminate ();
00046 void threads_execute (task* ts, nat n);
00047 void threads_simple_loop (nat nr_instances, nat nr_iterations);
00048 int  threads_get_number ();
00049 void threads_set_number (const int& n);
00050 int  get_number_cores ();
00051 
00052 } // namespace mmx
00053 
00054 #endif // __MMX_THREADS_HPP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines