1/*****************************************************************************
2
3  Licensed to Accellera Systems Initiative Inc. (Accellera) under one or
4  more contributor license agreements.  See the NOTICE file distributed
5  with this work for additional information regarding copyright ownership.
6  Accellera licenses this file to you under the Apache License, Version 2.0
7  (the "License"); you may not use this file except in compliance with the
8  License.  You may obtain a copy of the License at
9
10    http://www.apache.org/licenses/LICENSE-2.0
11
12  Unless required by applicable law or agreed to in writing, software
13  distributed under the License is distributed on an "AS IS" BASIS,
14  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
15  implied.  See the License for the specific language governing
16  permissions and limitations under the License.
17
18 *****************************************************************************/
19
20/*****************************************************************************
21
22  sc_cor_qt.h -- Coroutine implementation with QuickThreads.
23
24  Original Author: Martin Janssen, Synopsys, Inc., 2001-12-18
25
26  CHANGE LOG AT THE END OF THE FILE
27 *****************************************************************************/
28
29
30#ifndef SC_COR_QT_H
31#define SC_COR_QT_H
32
33
34#if !defined(_WIN32) && !defined(WIN32) && !defined(WIN64)  && !defined(SC_USE_PTHREADS)
35
36#include "sysc/kernel/sc_cor.h"
37#include "sysc/qt/qt.h"
38
39namespace sc_core {
40
41class sc_cor_pkg_qt;
42typedef sc_cor_pkg_qt sc_cor_pkg_t;
43
44// ----------------------------------------------------------------------------
45//  CLASS : sc_cor_qt
46//
47//  Coroutine class implemented with QuickThreads.
48// ----------------------------------------------------------------------------
49
50class sc_cor_qt
51: public sc_cor
52{
53public:
54
55    // constructor
56    sc_cor_qt()
57	: m_stack_size( 0 ), m_stack( 0 ), m_sp( 0 ), m_pkg( 0 )
58	{}
59
60    // destructor
61    virtual ~sc_cor_qt()
62        { delete[] (char*) m_stack; }
63
64    // switch stack protection on/off
65    virtual void stack_protect( bool enable );
66
67public:
68
69    std::size_t    m_stack_size;  // stack size
70    void*          m_stack;       // stack
71    qt_t*          m_sp;          // stack pointer
72
73    sc_cor_pkg_qt* m_pkg;         // the creating coroutine package
74
75private:
76
77    // disabled
78    sc_cor_qt( const sc_cor_qt& );
79    sc_cor_qt& operator = ( const sc_cor_qt& );
80};
81
82
83// ----------------------------------------------------------------------------
84//  CLASS : sc_cor_pkg_qt
85//
86//  Coroutine package class implemented with QuickThreads.
87// ----------------------------------------------------------------------------
88
89class sc_cor_pkg_qt
90: public sc_cor_pkg
91{
92public:
93
94    // constructor
95    sc_cor_pkg_qt( sc_simcontext* simc );
96
97    // destructor
98    virtual ~sc_cor_pkg_qt();
99
100    // create a new coroutine
101    virtual sc_cor* create( std::size_t stack_size, sc_cor_fn* fn, void* arg );
102
103    // yield to the next coroutine
104    virtual void yield( sc_cor* next_cor );
105
106    // abort the current coroutine (and resume the next coroutine)
107    virtual void abort( sc_cor* next_cor );
108
109    // get the main coroutine
110    virtual sc_cor* get_main();
111
112private:
113
114    static int instance_count;
115
116private:
117
118    // disabled
119    sc_cor_pkg_qt();
120    sc_cor_pkg_qt( const sc_cor_pkg_qt& );
121    sc_cor_pkg_qt& operator = ( const sc_cor_pkg_qt& );
122};
123
124} // namespace sc_core
125
126#endif
127
128// $Log: sc_cor_qt.h,v $
129// Revision 1.6  2011/08/29 18:04:32  acg
130//  Philipp A. Hartmann: miscellaneous clean ups.
131//
132// Revision 1.5  2011/08/26 20:46:09  acg
133//  Andy Goodrich: moved the modification log to the end of the file to
134//  eliminate source line number skew when check-ins are done.
135//
136// Revision 1.4  2011/02/18 20:27:14  acg
137//  Andy Goodrich: Updated Copyrights.
138//
139// Revision 1.3  2011/02/13 21:47:37  acg
140//  Andy Goodrich: update copyright notice.
141//
142// Revision 1.2  2008/05/22 17:06:25  acg
143//  Andy Goodrich: updated copyright notice to include 2008.
144//
145// Revision 1.1.1.1  2006/12/15 20:20:05  acg
146// SystemC 2.3
147//
148// Revision 1.3  2006/01/13 18:44:29  acg
149// Added $Log to record CVS changes into the source.
150//
151
152#endif
153
154// Taf!
155