1 /* thrnt.c - wrapper around NT threads */
4 #include "ldap_pvt_thread.h"
6 #if defined( HAVE_NT_THREADS )
9 openldap_thread_create( openldap_thread_t * thread,
10 openldap_thread_attr_t *attr,
11 void *(*start_routine)( void *), void *arg)
13 *thread = (openldap_thread_t)_beginthread( (void *) start_routine,
15 return ( (unsigned long)*thread == -1 ? -1 : 0 );
19 openldap_thread_exit( void *retval )
25 openldap_thread_join( openldap_thread_t thread, void **thread_return )
28 status = WaitForSingleObject( thread, INFINITE );
29 if (status == WAIT_FAILED) {
36 openldap_thread_kill( openldap_thread_t thread, int signo )
42 openldap_thread_yield( void )
48 openldap_thread_attr_init( openldap_thread_attr_t *attr )
55 openldap_thread_attr_destroy( openldap_thread_attr_t *attr )
61 openldap_thread_attr_setdetachstate( openldap_thread_attr_t *attr, int dstate )
68 openldap_thread_attr_getdetachstate( openldap_thread_attr_t *attr,
76 openldap_thread_cond_init( openldap_thread_cond_t *cond,
77 openldap_thread_condattr_t *attr )
79 *cond = CreateEvent( NULL, FALSE, FALSE, NULL );
84 openldap_thread_cond_destroy( openldap_thread_cond_t *cv )
91 openldap_thread_cond_signal( openldap_thread_cond_t *cond )
98 openldap_thread_cond_wait( openldap_thread_cond_t *cond,
99 openldap_thread_mutex_t *mutex )
101 ReleaseMutex( *mutex );
102 WaitForSingleObject( *cond, INFINITE );
103 WaitForSingleObject( *mutex, INFINITE );
108 openldap_thread_cond_broadcast( openldap_thread_cond_t *cv )
115 openldap_thread_mutex_init( openldap_thread_mutex_t *mutex,
116 openldap_thread_mutexattr_t *attr )
118 *mutex = CreateMutex( NULL, 0, NULL );
123 openldap_thread_mutex_destroy( openldap_thread_mutex_t *mutex )
125 CloseHandle( *mutex );
130 openldap_thread_mutex_lock( openldap_thread_mutex_t *mutex )
132 WaitForSingleObject( *mutex, INFINITE );
137 openldap_thread_mutex_unlock( openldap_thread_mutex_t *mutex )
139 ReleaseMutex( *mutex );
144 openldap_thread_mutex_trylock( openldap_thread_mutex_t *mp )
148 status = WaitForSingleObject( *mp, 0 );
149 if ( (status == WAIT_FAILED) || (status == WAIT_TIMEOUT) )