00001 /***************************************************************************** 00002 00003 The following code is derived, directly or indirectly, from the SystemC 00004 source code Copyright (c) 1996-2005 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.4 (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_cor_fiber.h -- Coroutine implementation with fibers. 00021 00022 Original Author: Martin Janssen, Synopsys, Inc., 2001-12-18 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_COR_FIBER_H 00037 #define SC_COR_FIBER_H 00038 00039 00040 #ifdef WIN32 00041 00042 #include "sysc/kernel/sc_cor.h" 00043 #include "sysc/kernel/sc_cmnhdr.h" 00044 00045 namespace sc_core { 00046 00047 class sc_cor_pkg_fiber; 00048 00049 00050 // ---------------------------------------------------------------------------- 00051 // CLASS : sc_cor_fiber 00052 // 00053 // Coroutine class implemented with QuickThreads. 00054 // ---------------------------------------------------------------------------- 00055 00056 class sc_cor_fiber 00057 : public sc_cor 00058 { 00059 #if( defined(_MSC_VER) && _MSC_VER >= 1300 ) 00060 typedef std::size_t size_t; 00061 #endif 00062 00063 public: 00064 00065 // constructor 00066 sc_cor_fiber() 00067 : m_stack_size( 0 ), m_fiber( 0 ), m_pkg( 0 ) 00068 {} 00069 00070 // destructor 00071 virtual ~sc_cor_fiber(); 00072 00073 public: 00074 00075 size_t m_stack_size; // stack size 00076 PVOID m_fiber; // fiber 00077 00078 sc_cor_pkg_fiber* m_pkg; // the creating coroutine package 00079 00080 private: 00081 00082 // disabled 00083 sc_cor_fiber( const sc_cor_fiber& ); 00084 sc_cor_fiber& operator = ( const sc_cor_fiber& ); 00085 }; 00086 00087 00088 // ---------------------------------------------------------------------------- 00089 // CLASS : sc_cor_pkg_fiber 00090 // 00091 // Coroutine package class implemented with QuickThreads. 00092 // ---------------------------------------------------------------------------- 00093 00094 class sc_cor_pkg_fiber 00095 : public sc_cor_pkg 00096 { 00097 #if( defined(_MSC_VER) && _MSC_VER >= 1300 ) 00098 typedef std::size_t size_t; 00099 #endif 00100 00101 public: 00102 00103 // constructor 00104 sc_cor_pkg_fiber( sc_simcontext* simc ); 00105 00106 // destructor 00107 virtual ~sc_cor_pkg_fiber(); 00108 00109 // create a new coroutine 00110 virtual sc_cor* create( size_t stack_size, sc_cor_fn* fn, void* arg ); 00111 00112 // yield to the next coroutine 00113 virtual void yield( sc_cor* next_cor ); 00114 00115 // abort the current coroutine (and resume the next coroutine) 00116 virtual void abort( sc_cor* next_cor ); 00117 00118 // get the main coroutine 00119 virtual sc_cor* get_main(); 00120 00121 private: 00122 00123 static int instance_count; 00124 00125 private: 00126 00127 // disabled 00128 sc_cor_pkg_fiber(); 00129 sc_cor_pkg_fiber( const sc_cor_pkg_fiber& ); 00130 sc_cor_pkg_fiber& operator = ( const sc_cor_pkg_fiber& ); 00131 }; 00132 00133 } // namespace sc_core 00134 00135 #endif // WIN32 00136 00137 00138 #endif 00139 00140 // Taf!
1.5.1