00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2004 by all Contributors. 00005 All Rights reserved. 00006 00007 The contents of this file are subject to the restrictions and limitations 00008 set forth in the SystemC Open Source License Version 2.3 (the "License"); 00009 You may not use this file except in compliance with such restrictions and 00010 limitations. You may obtain instructions on how to receive a copy of the 00011 License at http://www.systemc.org/. Software distributed by Contributors 00012 under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF 00013 ANY KIND, either express or implied. See the License for the specific 00014 language governing rights and limitations under the License. 00015 00016 *****************************************************************************/ 00017 00018 /***************************************************************************** 00019 00020 sc_join.h -- Join Process Synchronization Definition 00021 00022 Original Author: Andy Goodrich, Forte Design Systems, 5 May 2003 00023 00024 *****************************************************************************/ 00025 00026 /***************************************************************************** 00027 00028 MODIFICATION LOG - modifiers, enter your name, affiliation, date and 00029 changes you are making here. 00030 00031 Name, Affiliation, Date: 00032 Description of Modification: 00033 00034 *****************************************************************************/ 00035 00036 #ifndef SC_JOIN_H 00037 #define SC_JOIN_H 00038 00039 #include "systemc/kernel/sc_process_base.h" 00040 00041 00042 //============================================================================== 00043 // CLASS sc_join 00044 // 00045 // This class provides a way of waiting for a set of threads to complete their 00046 // execution. The threads whose completion is to be monitored are registered, 00047 // and upon their completion an event notification will occur. 00048 //============================================================================== 00049 class sc_join : public sc_process_monitor { 00050 friend class sc_process_base; 00051 public: 00052 inline sc_join(); 00053 virtual inline ~sc_join(); 00054 void add_process( const sc_process_handle& process_h ); 00055 virtual void signal(sc_thread_handle thread_p, int type); 00056 inline void wait(); 00057 00058 protected: 00059 void add_process( sc_process_base* process_p ); 00060 00061 protected: 00062 sc_event m_join_event; // Event to notify when all threads have reported. 00063 int m_threads_n; // # of threads still need to wait for. 00064 }; 00065 00066 sc_join::sc_join() : m_threads_n(0) { } 00067 00068 sc_join::~sc_join() {} 00069 00070 inline void sc_join::wait() { ::wait(m_join_event); } 00071 00072 #define SC_FORK \ 00073 { \ 00074 sc_process_handle forkees[] = { 00075 00076 #define SC_JOIN \ 00077 }; \ 00078 sc_join join; \ 00079 for ( unsigned int i = 0; i < sizeof(forkees)/sizeof(sc_thread_handle); \ 00080 i++ ) \ 00081 join.add_process(forkees[i]); \ 00082 join.wait(); \ 00083 } 00084 00085 00086 00087 #endif // SC_JOIN_H
1.2.18