log4cplus  2.0.0
threads-impl.h
Go to the documentation of this file.
00001 // -*- C++ -*-
00002 // Module:  Log4CPLUS
00003 // File:    threads.h
00004 // Created: 6/2001
00005 // Author:  Tad E. Smith
00006 //
00007 //
00008 // Copyright 2001-2015 Tad E. Smith
00009 //
00010 // Licensed under the Apache License, Version 2.0 (the "License");
00011 // you may not use this file except in compliance with the License.
00012 // You may obtain a copy of the License at
00013 //
00014 //     http://www.apache.org/licenses/LICENSE-2.0
00015 //
00016 // Unless required by applicable law or agreed to in writing, software
00017 // distributed under the License is distributed on an "AS IS" BASIS,
00018 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00019 // See the License for the specific language governing permissions and
00020 // limitations under the License.
00021 
00024 #ifndef LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_
00025 #define LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_
00026 
00027 #include <log4cplus/config.hxx>
00028 
00029 #if defined (LOG4CPLUS_HAVE_PRAGMA_ONCE)
00030 #pragma once
00031 #endif
00032 
00033 #if defined (_WIN32)
00034 #include <log4cplus/config/windowsh-inc.h>
00035 #endif
00036 #include <log4cplus/tstring.h>
00037 #include <log4cplus/helpers/pointer.h>
00038 #include <log4cplus/thread/threads.h>
00039 
00040 #if ! defined (INSIDE_LOG4CPLUS)
00041 #  error "This header must not be be used outside log4cplus' implementation files."
00042 #endif
00043 
00044 
00045 namespace log4cplus { namespace thread { namespace impl {
00046 
00047 
00048 #if defined (LOG4CPLUS_USE_PTHREADS)
00049 
00050 typedef pthread_t os_handle_type;
00051 typedef pthread_t os_id_type;
00052 
00053 
00054 inline
00055 pthread_t
00056 getCurrentThreadId ()
00057 {
00058     return pthread_self ();
00059 }
00060 
00061 
00062 #elif defined (LOG4CPLUS_USE_WIN32_THREADS)
00063 
00064 typedef HANDLE os_handle_type;
00065 typedef DWORD os_id_type;
00066 
00067 
00068 inline
00069 DWORD
00070 getCurrentThreadId ()
00071 {
00072     return GetCurrentThreadId ();
00073 }
00074 
00075 
00076 #elif defined (LOG4CPLUS_SINGLE_THREADED)
00077 
00078 typedef void * os_handle_type;
00079 typedef int os_id_type;
00080 
00081 
00082 inline
00083 int
00084 getCurrentThreadId ()
00085 {
00086     return 1;
00087 }
00088 
00089 
00090 #endif
00091 
00092 
00093 } } } // namespace log4cplus { namespace thread { namespace impl {
00094 
00095 
00096 #endif // LOG4CPLUS_IMPL_THREADS_IMPL_HEADER_