Mercurial > flash_v2
comparison packages/kernel/current/src/sync/mbox.cxx @ 0:3111d98ba7b3 ecos-v1_1-release
Initial commit of eCos version 1.1
| author | jlarmour |
|---|---|
| date | Tue, 11 May 1999 11:16:07 +0000 |
| parents | |
| children | 443894e2e912 |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:3111d98ba7b3 |
|---|---|
| 1 //========================================================================== | |
| 2 // | |
| 3 // mbox.cxx | |
| 4 // | |
| 5 // Mbox mbox template class implementation | |
| 6 // | |
| 7 //========================================================================== | |
| 8 //####COPYRIGHTBEGIN#### | |
| 9 // | |
| 10 // ------------------------------------------- | |
| 11 // The contents of this file are subject to the Cygnus eCos Public License | |
| 12 // Version 1.0 (the "License"); you may not use this file except in | |
| 13 // compliance with the License. You may obtain a copy of the License at | |
| 14 // http://sourceware.cygnus.com/ecos | |
| 15 // | |
| 16 // Software distributed under the License is distributed on an "AS IS" | |
| 17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the | |
| 18 // License for the specific language governing rights and limitations under | |
| 19 // the License. | |
| 20 // | |
| 21 // The Original Code is eCos - Embedded Cygnus Operating System, released | |
| 22 // September 30, 1998. | |
| 23 // | |
| 24 // The Initial Developer of the Original Code is Cygnus. Portions created | |
| 25 // by Cygnus are Copyright (C) 1998 Cygnus Solutions. All Rights Reserved. | |
| 26 // ------------------------------------------- | |
| 27 // | |
| 28 //####COPYRIGHTEND#### | |
| 29 //========================================================================== | |
| 30 //#####DESCRIPTIONBEGIN#### | |
| 31 // | |
| 32 // Author(s): hmt | |
| 33 // Contributors: hmt | |
| 34 // Date: 1998-02-11 | |
| 35 // Purpose: Mbox implementation | |
| 36 // Description: This file contains the implementations of the mbox class | |
| 37 // | |
| 38 //####DESCRIPTIONEND#### | |
| 39 // | |
| 40 //========================================================================== | |
| 41 | |
| 42 #include <pkgconf/kernel.h> | |
| 43 | |
| 44 #include <cyg/kernel/ktypes.h> // base kernel types | |
| 45 #include <cyg/infra/cyg_trac.h> // tracing macros | |
| 46 #include <cyg/infra/cyg_ass.h> // assertion macros | |
| 47 #include <cyg/kernel/instrmnt.h> // instrumentation | |
| 48 | |
| 49 #include <cyg/kernel/thread.inl> // Cyg_Thread inlines | |
| 50 | |
| 51 #include <cyg/kernel/mbox.hxx> // our own header | |
| 52 | |
| 53 #ifndef CYGIMP_MBOXT_INLINE // force inlining | |
| 54 #define CYGIMP_MBOXT_INLINE // of implementation | |
| 55 #endif | |
| 56 | |
| 57 #ifdef CYGIMP_MBOX_USE_MBOXT_PLAIN | |
| 58 #include <cyg/kernel/mboxt.inl> // mbox template implementation | |
| 59 #else | |
| 60 #include <cyg/kernel/mboxt2.inl> // mbox template implementation | |
| 61 #endif | |
| 62 | |
| 63 // ------------------------------------------------------------------------- | |
| 64 // This module exists to cause exactly one instance of these functions to | |
| 65 // exist; this is just like a vanilla class, except we use the template | |
| 66 // class to acquire an implementation. The template functions are inlined | |
| 67 // in each of these methods. | |
| 68 | |
| 69 | |
| 70 // ------------------------------------------------------------------------- | |
| 71 // Constructor | |
| 72 | |
| 73 Cyg_Mbox::Cyg_Mbox() | |
| 74 { | |
| 75 } | |
| 76 | |
| 77 // ------------------------------------------------------------------------- | |
| 78 // Destructor | |
| 79 | |
| 80 Cyg_Mbox::~Cyg_Mbox() | |
| 81 { | |
| 82 } | |
| 83 | |
| 84 // ------------------------------------------------------------------------- | |
| 85 // debugging/assert function | |
| 86 | |
| 87 #ifdef CYGDBG_USE_ASSERTS | |
| 88 cyg_bool | |
| 89 Cyg_Mbox::check_this(cyg_assert_class_zeal zeal) | |
| 90 { | |
| 91 return m.check_this(zeal); | |
| 92 } | |
| 93 #endif | |
| 94 | |
| 95 // ------------------------------------------------------------------------- | |
| 96 // now the members themselves: | |
| 97 | |
| 98 void * | |
| 99 Cyg_Mbox::get() | |
| 100 { | |
| 101 void * p; | |
| 102 if ( ! m.get( p ) ) | |
| 103 return NULL; | |
| 104 return p; | |
| 105 } | |
| 106 | |
| 107 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 108 void * | |
| 109 Cyg_Mbox::get( cyg_tick_count timeout ) | |
| 110 { | |
| 111 void * p; | |
| 112 if ( ! m.get( p, timeout ) ) | |
| 113 return NULL; | |
| 114 return p; | |
| 115 } | |
| 116 #endif | |
| 117 | |
| 118 void * | |
| 119 Cyg_Mbox::tryget() | |
| 120 { | |
| 121 void * p; | |
| 122 if ( ! m.tryget( p ) ) | |
| 123 return NULL; | |
| 124 return p; | |
| 125 } | |
| 126 | |
| 127 #ifdef CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT | |
| 128 cyg_bool | |
| 129 Cyg_Mbox::put( void *item ) | |
| 130 { | |
| 131 return m.put( item ); | |
| 132 } | |
| 133 | |
| 134 #ifdef CYGFUN_KERNEL_THREADS_TIMER | |
| 135 cyg_bool | |
| 136 Cyg_Mbox::put( void *item, cyg_tick_count timeout ) | |
| 137 { | |
| 138 return m.put( item, timeout ); | |
| 139 } | |
| 140 #endif | |
| 141 #endif // CYGMFN_KERNEL_SYNCH_MBOXT_PUT_CAN_WAIT | |
| 142 | |
| 143 cyg_bool | |
| 144 Cyg_Mbox::tryput( void *item ) | |
| 145 { | |
| 146 return m.tryput( item ); | |
| 147 } | |
| 148 | |
| 149 void * | |
| 150 Cyg_Mbox::peek_item() // Get next item to be returned | |
| 151 { | |
| 152 void *p; | |
| 153 if ( ! m.peek_item( p ) ) | |
| 154 return NULL; | |
| 155 return p; | |
| 156 } | |
| 157 | |
| 158 // ------------------------------------------------------------------------- | |
| 159 // EOF mbox.cxx |
