annotate packages/kernel/current/src/sync/mbox.cxx @ 210:d2c90368aeef

Merge from eCos master repository on 2002-05-23-21:39:14-BST
author jlarmour
date Thu, 23 May 2002 22:59:51 +0000
parents e0c0827131d1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
1 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
2 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
3 // mbox.cxx
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
4 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
5 // Mbox mbox template class implementation
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
6 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
7 //==========================================================================
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
8 //####ECOSGPLCOPYRIGHTBEGIN####
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
9 // -------------------------------------------
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
10 // This file is part of eCos, the Embedded Configurable Operating System.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
11 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
12 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
13 // eCos is free software; you can redistribute it and/or modify it under
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
14 // the terms of the GNU General Public License as published by the Free
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
15 // Software Foundation; either version 2 or (at your option) any later version.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
16 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
17 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
18 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
19 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
20 // for more details.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
21 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
22 // You should have received a copy of the GNU General Public License along
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
23 // with eCos; if not, write to the Free Software Foundation, Inc.,
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
24 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
25 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
26 // As a special exception, if other files instantiate templates or use macros
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
27 // or inline functions from this file, or you compile this file and link it
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
28 // with other works to produce a work based on this file, this file does not
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
29 // by itself cause the resulting work to be covered by the GNU General Public
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
30 // License. However the source code for this file must still be made available
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
31 // in accordance with section (3) of the GNU General Public License.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
32 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
33 // This exception does not invalidate any other reasons why a work based on
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
34 // this file might be covered by the GNU General Public License.
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
35 //
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
36 // Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
210
d2c90368aeef Merge from eCos master repository on 2002-05-23-21:39:14-BST
jlarmour
parents: 208
diff changeset
37 // at http://sources.redhat.com/ecos/ecos-license/
208
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
38 // -------------------------------------------
e0c0827131d1 Merge from eCos master repository on 2002-05-20-20:11:54-BST
jlarmour
parents: 66
diff changeset
39 //####ECOSGPLCOPYRIGHTEND####
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
40 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
41 //#####DESCRIPTIONBEGIN####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
42 //
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
43 // Author(s): hmt
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
44 // Contributors: hmt
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
45 // Date: 1998-02-11
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
46 // Purpose: Mbox implementation
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
47 // Description: This file contains the implementations of the mbox class
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
48 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
49 //####DESCRIPTIONEND####
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
50 //
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
51 //==========================================================================
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
52
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
53 #include <pkgconf/kernel.h>
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
54
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
55 #include <cyg/kernel/ktypes.h> // base kernel types
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
56 #include <cyg/infra/cyg_trac.h> // tracing macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
57 #include <cyg/infra/cyg_ass.h> // assertion macros
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
58 #include <cyg/kernel/instrmnt.h> // instrumentation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
59
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
60 #include <cyg/kernel/thread.inl> // Cyg_Thread inlines
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
61
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
62 #include <cyg/kernel/mbox.hxx> // our own header
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
63
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
64 #ifndef CYGIMP_MBOXT_INLINE // force inlining
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
65 #define CYGIMP_MBOXT_INLINE // of implementation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
66 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
67
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
68 #ifdef CYGIMP_MBOX_USE_MBOXT_PLAIN
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
69 #include <cyg/kernel/mboxt.inl> // mbox template implementation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
70 #else
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
71 #include <cyg/kernel/mboxt2.inl> // mbox template implementation
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
72 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
73
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
74 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
75 // This module exists to cause exactly one instance of these functions to
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
76 // exist; this is just like a vanilla class, except we use the template
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
77 // class to acquire an implementation. The template functions are inlined
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
78 // in each of these methods.
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
79
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
80
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
81 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
82 // Constructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
83
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
84 Cyg_Mbox::Cyg_Mbox()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
85 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
86 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
87
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
88 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
89 // Destructor
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
90
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
91 Cyg_Mbox::~Cyg_Mbox()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
92 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
93 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
94
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
95 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
96 // debugging/assert function
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
97
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
98 #ifdef CYGDBG_USE_ASSERTS
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
99 cyg_bool
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
100 Cyg_Mbox::check_this(cyg_assert_class_zeal zeal) const
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
101 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
102 return m.check_this(zeal);
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
103 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
104 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
105
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
106 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
107 // now the members themselves:
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
108
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
109 void *
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
110 Cyg_Mbox::get()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
111 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
112 void * p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
113 if ( ! m.get( p ) )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
114 return NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
115 return p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
116 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
117
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
118 #ifdef CYGFUN_KERNEL_THREADS_TIMER
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
119 void *
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
120 Cyg_Mbox::get( cyg_tick_count timeout )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
121 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
122 void * p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
123 if ( ! m.get( p, timeout ) )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
124 return NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
125 return p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
126 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
127 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
128
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
129 void *
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
130 Cyg_Mbox::tryget()
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
131 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
132 void * p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
133 if ( ! m.tryget( p ) )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
134 return NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
135 return p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
136 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
137
2
443894e2e912 Block commit of eCos version 1.2.1
jlarmour
parents: 0
diff changeset
138 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT
0
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
139 cyg_bool
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
140 Cyg_Mbox::put( void *item )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
141 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
142 return m.put( item );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
143 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
144
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
145 #ifdef CYGFUN_KERNEL_THREADS_TIMER
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
146 cyg_bool
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
147 Cyg_Mbox::put( void *item, cyg_tick_count timeout )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
148 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
149 return m.put( item, timeout );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
150 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
151 #endif
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
152 #endif // CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
153
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
154 cyg_bool
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
155 Cyg_Mbox::tryput( void *item )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
156 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
157 return m.tryput( item );
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
158 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
159
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
160 void *
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
161 Cyg_Mbox::peek_item() // Get next item to be returned
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
162 {
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
163 void *p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
164 if ( ! m.peek_item( p ) )
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
165 return NULL;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
166 return p;
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
167 }
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
168
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
169 // -------------------------------------------------------------------------
3111d98ba7b3 Initial commit of eCos version 1.1
jlarmour
parents:
diff changeset
170 // EOF mbox.cxx