Титульная страница | Пространства имен | Алфавитный указатель | Классы | Файлы | Члены пространства имен | Члены классов | Описания | Примеры

threads_1/win32/h/os_thread.hpp

См. документацию.
00001 /* 00002 00003 threads_1: Multithreading support library 00004 Yauheni A. Akhotnikau (C) 2002-2003 00005 eao197@yahoo.com 00006 ------------------------------------------------- 00007 00008 Permission is granted to anyone to use this software for any purpose on any 00009 computer system, and to redistribute it freely, subject to the following 00010 restrictions: 00011 00012 1. This software is distributed in the hope that it will be useful, 00013 but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00015 00016 2. The origin of this software must not be misrepresented, either by 00017 explicit claim or by omission. 00018 00019 3. Altered versions must be plainly marked as such, and must not be 00020 misrepresented as being the original software. 00021 00022 ------------------------------------------------- 00023 00024 */ 00034 #if !defined( _THREADS_1__WIN32__OS_THREAD_HPP_ ) 00035 #define _THREADS_1__WIN32__OS_THREAD_HPP_ 00036 00037 #define WIN32_LEAN_AND_MEAN 00038 #include <windows.h> 00039 00040 #include <cpp_util_2/h/nocopy.hpp> 00041 00042 #include <threads_1/h/threads.hpp> 00043 00044 namespace threads_1 00045 { 00046 00050 class _os_thread_t : 00051 public cpp_util_2::nocopy_t 00052 { 00053 protected : 00055 00063 HANDLE m_tid; 00064 00066 00070 thread_t * m_controlled_obj; 00071 00072 public : 00073 _os_thread_t() 00074 : 00075 m_tid( 0 ), 00076 m_controlled_obj( 0 ), 00077 m_cv( m_sem ) 00078 { 00079 } 00080 ~_os_thread_t() 00081 { 00082 if( m_tid ) 00083 CloseHandle( m_tid ); 00084 } 00085 00087 00091 void 00092 set_controlled_obj( 00093 thread_t * obj ) 00094 { 00095 m_controlled_obj = obj; 00096 } 00097 00099 void 00100 start(); 00101 00103 void 00104 wait() 00105 { 00106 WaitForSingleObject( m_tid, INFINITE ); 00107 } 00108 00109 protected : 00115 mutex_sem_t m_sem; 00119 cond_var_t m_cv; 00120 00121 #ifdef _MSC_VER 00122 static void __cdecl start_thread( _os_thread_t * pthread ); 00123 #else 00124 static void start_thread( _os_thread_t * pthread ); 00125 #endif 00126 }; 00127 00130 00137 inline void 00138 _os_sleep_thread( unsigned long msec ) 00139 { 00140 Sleep( msec ); 00141 } 00142 00143 } /* namespace threads_1 */ 00144 00145 #endif

Документация по threads_1. Последние изменения: Wed Aug 4 06:46:01 2004. Создано системой doxygen 1.3.7
Hosted by uCoz