SystemC  2.3.2
Accellera SystemC proof-of-concept library
sc_mutex.h
Go to the documentation of this file.
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_mutex.h -- The sc_mutex primitive channel class.
23 */
33 #ifndef SC_MUTEX_H
34 #define SC_MUTEX_H
35 
36 #include "sysc/kernel/sc_event.h"
37 #include "sysc/kernel/sc_object.h"
38 #include "sysc/kernel/sc_wait.h"
40 
41 namespace sc_core {
42 
50 : public sc_mutex_if,
51  public sc_object
52 {
53 public:
54 
55  // constructors and destructor
56 
57  sc_mutex();
58  explicit sc_mutex( const char* name_ );
59  virtual ~sc_mutex();
60 
61 
62  // interface methods
63 
64  // blocks until mutex could be locked
65  virtual int lock();
66 
67  // returns -1 if mutex could not be locked
68  virtual int trylock();
69 
70  // returns -1 if mutex was not locked by caller
71  virtual int unlock();
72 
73  virtual const char* kind() const
74  { return "sc_mutex"; }
75 
76 protected:
77 
78  // support methods
79 
80  bool in_use() const
81  { return ( m_owner != 0 ); }
82 
83 protected:
84 
87 
88 private:
89 
90  // disabled
91  sc_mutex( const sc_mutex& );
92  sc_mutex& operator = ( const sc_mutex& );
93 };
94 
95 } // namespace sc_core
96 
97 //$Log: sc_mutex.h,v $
98 //Revision 1.4 2011/08/26 20:45:41 acg
99 // Andy Goodrich: moved the modification log to the end of the file to
100 // eliminate source line number skew when check-ins are done.
101 //
102 //Revision 1.3 2011/02/18 20:23:45 acg
103 // Andy Goodrich: Copyright update.
104 //
105 //Revision 1.2 2010/11/02 16:31:01 acg
106 // Andy Goodrich: changed object derivation to use sc_object rather than
107 // sc_prim_channel as the parent class.
108 //
109 //Revision 1.1.1.1 2006/12/15 20:20:04 acg
110 //SystemC 2.3
111 //
112 //Revision 1.2 2006/01/03 23:18:26 acg
113 //Changed copyright to include 2006.
114 //
115 //Revision 1.1.1.1 2005/12/19 23:16:43 acg
116 //First check in of SystemC 2.1 into its own archive.
117 //
118 //Revision 1.10 2005/09/15 23:01:51 acg
119 //Added std:: prefix to appropriate methods and types to get around
120 //issues with the Edison Front End.
121 //
122 //Revision 1.9 2005/06/10 22:43:55 acg
123 //Added CVS change log annotation.
124 //
125 
126 #endif
127 
128 // Taf!
The sc_mutex_if interface class.
Abstract base class of all SystemC `simulation' objects.
Definition: sc_object.h:61
The sc_mutex_if interface class.
Definition: sc_mutex_if.h:46
bool in_use() const
Definition: sc_mutex.h:80
Wait() and related functions.
The event class.
Definition: sc_event.h:256
The sc_mutex primitive channel class.
Definition: sc_mutex.h:49
sc_process_b * m_owner
Definition: sc_mutex.h:85
Abstract base class of all SystemC `simulation' objects.
sc_event m_free
Definition: sc_mutex.h:86
#define SC_API
Definition: sc_cmnhdr.h:168
Original Author: Martin Janssen, Synopsys, Inc., 2001-05-21.
virtual const char * kind() const
Definition: sc_mutex.h:73