rc_join.h

Go to the documentation of this file.
00001 // vim:set et sts=4 ts=4 tw=75 sw=4 ai ci cin cino=g0,t0:
00002 /*
00003  * Copyright (C) 2007, Technical Computer Science Group,
00004  *                     University of Bonn
00005  *
00006  * This file is part of the ReChannel library.
00007  *
00008  * The ReChannel library is free software; you can redistribute it and/or
00009  * modify it under the terms of the GNU General Public License as
00010  * published by the Free Software Foundation; either version 2 of the
00011  * License, or (at your option) any later version.
00012  *
00013  * This library is distributed in the hope that it will be
00014  * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU General Public License
00019  * along with this library; see the file COPYING. If not, write to the
00020  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
00021  * Boston, MA 02110-1301, USA.
00022  *
00023  * Authors: Andreas Raabe and Armin Felke. Implementation by Armin Felke.
00024  *          {raabe, felke}@cs.uni-bonn.de
00025  */
00037 #ifndef RC_JOIN_H_
00038 #define RC_JOIN_H_
00039 
00040 #include "ReChannel/core/rc_process.h"
00041 
00042 namespace ReChannel {
00043 
00047 class rc_join
00048 {
00049 private:
00050     typedef std::vector<rc_process_handle> hproc_vector;
00051 
00052 public:
00053     rc_join();
00054 
00055     void add_process(rc_process_handle hproc)
00056         { p_hproc_vector.push_back(hproc); }
00057 
00058     unsigned int get_process_count()
00059         { return p_hproc_vector.size(); }
00060 
00061     void wait();
00062 
00063     void reset()
00064         { p_hproc_vector.clear(); }
00065 
00066 private:
00067     hproc_vector p_hproc_vector;
00068 
00069 private:
00070     // disabled
00071     rc_join(const rc_join& orig);
00072     rc_join& operator =(const rc_join& orig);
00073 };
00074 
00075 } // namespace ReChannel
00076 
00077 #define RC_RECONFIGURABLE_FORK \
00078     { \
00079         ::ReChannel::rc_process_handle proc_arr[] = {
00080 
00081 #define RC_RECONFIGURABLE_JOIN \
00082         }; \
00083         ::ReChannel::rc_join join; \
00084         for (unsigned int i = 0; \
00085             i < sizeof(proc_arr)/sizeof(::ReChannel::rc_process_handle); \
00086             i++) \
00087         { \
00088             join.add_process(proc_arr[i]); \
00089         } \
00090         join.wait(); \
00091     }
00092 
00096 #define RC_FORK \
00097     RC_RECONFIGURABLE_FORK
00098 
00102 #define RC_JOIN \
00103     RC_RECONFIGURABLE_JOIN
00104 
00105 #endif // RC_JOIN_H_
00106 
00107 //
00108 // $Id: rc_join.h,v 1.7 2007/11/23 13:24:55 felke Exp $
00109 // $Source: /var/cvs/projekte/ReChannel-v2/src/ReChannel/components/rc_join.h,v $
00110 //

Generated on Tue Jan 1 23:13:38 2008 for ReChannel by  doxygen 1.5.3