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

threads_1/posix/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__POSIX__OS_THREAD_HPP_ ) 00035 #define _THREADS_1__POSIX__OS_THREAD_HPP_ 00036 00037 #include <unistd.h> 00038 #include <pthread.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 00058 pthread_t m_tid; 00059 00061 00065 thread_t * m_controlled_obj; 00066 00067 public : 00068 _os_thread_t() 00069 : 00070 m_tid( 0 ), 00071 m_controlled_obj( 0 ), 00072 m_cv( m_sem ) 00073 { 00074 } 00075 ~_os_thread_t() 00076 { 00077 } 00078 00080 00084 void 00085 set_controlled_obj( 00086 thread_t * obj ) 00087 { 00088 m_controlled_obj = obj; 00089 } 00090 00092 void 00093 start(); 00094 00096 void 00097 wait() 00098 { 00099 pthread_join( m_tid, 0 ); 00100 } 00101 00102 protected : 00108 mutex_sem_t m_sem; 00112 cond_var_t m_cv; 00113 00114 static void * 00115 start_thread( _os_thread_t * pthread ); 00116 }; 00117 00120 00127 inline void 00128 _os_sleep_thread( unsigned long msec ) 00129 { 00130 sleep( msec / 1000 ); 00131 } 00132 00133 } /* namespace threads_1 */ 00134 00135 #endif

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