19 static void * vs_thread_start(
void *info )
25 struct VSThread::Private
34 _internal =
new Private;
35 _internal->detach = detached;
37 ::pthread_init( &_internal->t );
39 ::pthread_attr_init( &_internal->ta );
44 ::pthread_attr_destroy( &_internal->ta );
52 if (_internal->detach) {
53 ret = ::pthread_attr_setdetachstate( &_internal->ta,
54 PTHREAD_CREATE_DETACHED );
56 perror(
"pthread_attr_setdetachstate failed" );
59 ret = ::pthread_attr_setscope( &_internal->ta, PTHREAD_SCOPE_SYSTEM );
61 perror(
"pthread_attr_setscope failed" );
65 #if defined (_AIX) && defined (_AIX32_THREADS)
67 err = ::pthread_create( &_internal->t,
72 err = ::pthread_create( &_internal->t,
78 perror(
"pthread_create failed" );
85 if (_internal->detach ==
false)
86 ::pthread_join( _internal->t, NULL );
93 struct VSMutex::Private
95 #if defined (linux) || defined (_AIX)
96 pthread_mutexattr_t attr;
103 #if defined (linux) || defined (_AIX)
105 int ret = ::pthread_mutexattr_init( &
_internal->attr );
107 perror(
"pthread_mutexattr_init failed (ignored)" );
108 ret = ::pthread_mutex_init( &
_internal->lck, NULL );
117 ::pthread_mutexattr_settype( &
_internal->attr, PTHREAD_MUTEX_ERRORCHECK );
119 ::pthread_mutexattr_settype( &
_internal->attr, PTHREAD_MUTEX_NORMAL );
126 ::pthread_mutexattr_setpshared( &
_internal->attr, PTHREAD_PROCESS_PRIVATE );
131 perror(
"pthread_mutex_init failed" );
134 int ret = ::pthread_mutex_init( &
_internal->lck, NULL );
136 perror(
"pthread_mutex_init failed" );
142 int ret = ::pthread_mutex_destroy( &
_internal->lck );
144 perror(
"pthread_mutex_destroy failed" );
145 #if defined (linux) || defined (_AIX)
146 ret = ::pthread_mutexattr_destroy( &
_internal->attr );
148 perror(
"pthread_mutexattr_destroy failed" );
155 int ret = ::pthread_mutex_lock( &
_internal->lck );
157 perror(
"pthread_mutex_lock failed" );
162 int ret = ::pthread_mutex_unlock( &
_internal->lck );
164 perror(
"pthread_mutex_unlock failed" );
171 struct VSCond::Private
173 pthread_condattr_t attr;
179 _internal =
new Private;
180 int ret = ::pthread_condattr_init( &_internal->attr );
182 perror(
"pthread_condattr_init failed" );
184 ret = ::pthread_cond_init( &_internal->ctr, &_internal->attr );
186 perror(
"pthread_cond_init failed" );
192 int ret = ::pthread_cond_destroy( &_internal->ctr );
194 perror(
"pthread_cond_destroy failed" );
195 ret = ::pthread_condattr_destroy( &_internal->attr );
197 perror(
"pthread_condattr_destroy failed" );
203 int ret = ::pthread_cond_wait( &_internal->ctr, &mx.
_internal->lck );
205 perror(
"pthread_cond_wait failed" );
210 int ret = ::pthread_cond_signal( &_internal->ctr );
212 perror(
"pthread_cond_signal failed" );
217 int ret = ::pthread_cond_broadcast( &_internal->ctr );
219 perror(
"pthread_cond_broadcast failed" );