log4cplus
1.1.0
|
00001 // -*- C++ -*- 00002 // Copyright (C) 2010, Vaclav Haisman. All rights reserved. 00003 // 00004 // Redistribution and use in source and binary forms, with or without modifica- 00005 // tion, are permitted provided that the following conditions are met: 00006 // 00007 // 1. Redistributions of source code must retain the above copyright notice, 00008 // this list of conditions and the following disclaimer. 00009 // 00010 // 2. Redistributions in binary form must reproduce the above copyright notice, 00011 // this list of conditions and the following disclaimer in the documentation 00012 // and/or other materials provided with the distribution. 00013 // 00014 // THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES, 00015 // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND 00016 // FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 00017 // APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, 00018 // INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU- 00019 // DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 00020 // OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 00021 // ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00022 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 00023 // THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00024 00025 #ifndef LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H 00026 #define LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H 00027 00028 #include <log4cplus/config.hxx> 00029 00030 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE) 00031 #pragma once 00032 #endif 00033 00034 #if (defined (LOG4CPLUS_INLINES_ARE_EXPORTED) \ 00035 && defined (LOG4CPLUS_BUILD_DLL)) \ 00036 || defined (LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL) 00037 #include <log4cplus/thread/syncprims.h> 00038 00039 #if defined (LOG4CPLUS_SINGLE_THREADED) 00040 # define LOG4CPLUS_THREADED(x) 00041 #else 00042 # include <log4cplus/thread/impl/syncprims-impl.h> 00043 # define LOG4CPLUS_THREADED(x) (x) 00044 #endif 00045 00046 00047 namespace log4cplus { namespace thread { 00048 00049 00050 // 00051 // 00052 // 00053 00054 LOG4CPLUS_INLINE_EXPORT 00055 MutexImplBase::~MutexImplBase () 00056 { } 00057 00058 00059 // 00060 // 00061 // 00062 00063 LOG4CPLUS_INLINE_EXPORT 00064 Mutex::Mutex (Mutex::Type t) 00065 : mtx (LOG4CPLUS_THREADED (new impl::Mutex (t)) + 0) 00066 { } 00067 00068 00069 LOG4CPLUS_INLINE_EXPORT 00070 Mutex::~Mutex () 00071 { 00072 LOG4CPLUS_THREADED (delete static_cast<impl::Mutex *>(mtx)); 00073 } 00074 00075 00076 LOG4CPLUS_INLINE_EXPORT 00077 void 00078 Mutex::lock () const 00079 { 00080 LOG4CPLUS_THREADED (static_cast<impl::Mutex *>(mtx)->lock ()); 00081 } 00082 00083 00084 LOG4CPLUS_INLINE_EXPORT 00085 void 00086 Mutex::unlock () const 00087 { 00088 LOG4CPLUS_THREADED (static_cast<impl::Mutex *>(mtx)->unlock ()); 00089 } 00090 00091 00092 // 00093 // 00094 // 00095 00096 LOG4CPLUS_INLINE_EXPORT 00097 SemaphoreImplBase::~SemaphoreImplBase () 00098 { } 00099 00100 00101 // 00102 // 00103 // 00104 00105 LOG4CPLUS_INLINE_EXPORT 00106 Semaphore::Semaphore (unsigned LOG4CPLUS_THREADED (max), 00107 unsigned LOG4CPLUS_THREADED (initial)) 00108 : sem (LOG4CPLUS_THREADED (new impl::Semaphore (max, initial)) + 0) 00109 { } 00110 00111 00112 LOG4CPLUS_INLINE_EXPORT 00113 Semaphore::~Semaphore () 00114 { 00115 LOG4CPLUS_THREADED (delete static_cast<impl::Semaphore *>(sem)); 00116 } 00117 00118 00119 LOG4CPLUS_INLINE_EXPORT 00120 void 00121 Semaphore::lock () const 00122 { 00123 LOG4CPLUS_THREADED (static_cast<impl::Semaphore *>(sem)->lock ()); 00124 } 00125 00126 00127 LOG4CPLUS_INLINE_EXPORT 00128 void 00129 Semaphore::unlock () const 00130 { 00131 LOG4CPLUS_THREADED (static_cast<impl::Semaphore *>(sem)->unlock ()); 00132 } 00133 00134 00135 // 00136 // 00137 // 00138 00139 LOG4CPLUS_INLINE_EXPORT 00140 FairMutexImplBase::~FairMutexImplBase () 00141 { } 00142 00143 00144 // 00145 // 00146 // 00147 00148 LOG4CPLUS_INLINE_EXPORT 00149 FairMutex::FairMutex () 00150 : mtx (LOG4CPLUS_THREADED (new impl::FairMutex) + 0) 00151 { } 00152 00153 00154 LOG4CPLUS_INLINE_EXPORT 00155 FairMutex::~FairMutex () 00156 { 00157 LOG4CPLUS_THREADED (delete static_cast<impl::FairMutex *>(mtx)); 00158 } 00159 00160 00161 LOG4CPLUS_INLINE_EXPORT 00162 void 00163 FairMutex::lock () const 00164 { 00165 LOG4CPLUS_THREADED (static_cast<impl::FairMutex *>(mtx)->lock ()); 00166 } 00167 00168 00169 LOG4CPLUS_INLINE_EXPORT 00170 void 00171 FairMutex::unlock () const 00172 { 00173 LOG4CPLUS_THREADED (static_cast<impl::FairMutex *>(mtx)->unlock ()); 00174 } 00175 00176 00177 // 00178 // 00179 // 00180 00181 LOG4CPLUS_INLINE_EXPORT 00182 ManualResetEventImplBase::~ManualResetEventImplBase () 00183 { } 00184 00185 00186 // 00187 // 00188 // 00189 00190 LOG4CPLUS_INLINE_EXPORT 00191 ManualResetEvent::ManualResetEvent (bool LOG4CPLUS_THREADED (sig)) 00192 : ev (LOG4CPLUS_THREADED (new impl::ManualResetEvent (sig)) + 0) 00193 { } 00194 00195 00196 LOG4CPLUS_INLINE_EXPORT 00197 ManualResetEvent::~ManualResetEvent () 00198 { 00199 LOG4CPLUS_THREADED (delete static_cast<impl::ManualResetEvent *>(ev)); 00200 } 00201 00202 00203 LOG4CPLUS_INLINE_EXPORT 00204 void 00205 ManualResetEvent::signal () const 00206 { 00207 LOG4CPLUS_THREADED (static_cast<impl::ManualResetEvent *>(ev)->signal ()); 00208 } 00209 00210 00211 LOG4CPLUS_INLINE_EXPORT 00212 void 00213 ManualResetEvent::wait () const 00214 { 00215 LOG4CPLUS_THREADED (static_cast<impl::ManualResetEvent *>(ev)->wait ()); 00216 } 00217 00218 00219 LOG4CPLUS_INLINE_EXPORT 00220 bool 00221 ManualResetEvent::timed_wait (unsigned long LOG4CPLUS_THREADED (msec)) const 00222 { 00223 #if defined (LOG4CPLUS_SINGLE_THREADED) 00224 return true; 00225 #else 00226 return static_cast<impl::ManualResetEvent *>(ev)->timed_wait (msec); 00227 #endif 00228 } 00229 00230 00231 LOG4CPLUS_INLINE_EXPORT 00232 void 00233 ManualResetEvent::reset () const 00234 { 00235 LOG4CPLUS_THREADED (static_cast<impl::ManualResetEvent *>(ev)->reset ()); 00236 } 00237 00238 00239 // 00240 // 00241 // 00242 00243 LOG4CPLUS_INLINE_EXPORT 00244 SharedMutexImplBase::~SharedMutexImplBase () 00245 { } 00246 00247 00248 // 00249 // 00250 // 00251 00252 LOG4CPLUS_INLINE_EXPORT 00253 SharedMutex::SharedMutex () 00254 : sm (LOG4CPLUS_THREADED (new impl::SharedMutex) + 0) 00255 { } 00256 00257 00258 LOG4CPLUS_INLINE_EXPORT 00259 SharedMutex::~SharedMutex () 00260 { } 00261 00262 00263 LOG4CPLUS_INLINE_EXPORT 00264 void 00265 SharedMutex::rdlock () const 00266 { 00267 LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->rdlock ()); 00268 } 00269 00270 00271 LOG4CPLUS_INLINE_EXPORT 00272 void 00273 SharedMutex::wrlock () const 00274 { 00275 LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->wrlock ()); 00276 } 00277 00278 00279 LOG4CPLUS_INLINE_EXPORT 00280 void 00281 SharedMutex::rdunlock () const 00282 { 00283 LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->rdunlock ()); 00284 } 00285 00286 00287 LOG4CPLUS_INLINE_EXPORT 00288 void 00289 SharedMutex::wrunlock () const 00290 { 00291 LOG4CPLUS_THREADED (static_cast<impl::SharedMutex *>(sm)->wrunlock ()); 00292 } 00293 00294 00295 } } // namespace log4cplus { namespace thread { 00296 00297 #endif // LOG4CPLUS_ENABLE_SYNCPRIMS_PUB_IMPL 00298 00299 #endif // LOG4CPLUS_THREAD_SYNCPRIMS_PUB_IMPL_H