Home | History | Annotate | Download | only in libxml2

Lines Matching refs:tok

192     xmlMutexPtr tok;
194 if ((tok = malloc(sizeof(xmlMutex))) == NULL)
198 pthread_mutex_init(&tok->lock, NULL);
200 tok->mutex = CreateMutex(NULL, FALSE, NULL);
202 if ((tok->sem = create_sem(1, "xmlMutex")) < B_OK) {
203 free(tok);
206 tok->tid = -1;
208 return (tok);
213 * @tok: the simple mutex
219 xmlFreeMutex(xmlMutexPtr tok)
221 if (tok == NULL)
226 pthread_mutex_destroy(&tok->lock);
228 CloseHandle(tok->mutex);
230 delete_sem(tok->sem);
232 free(tok);
237 * @tok: the simple mutex
242 xmlMutexLock(xmlMutexPtr tok)
244 if (tok == NULL)
248 pthread_mutex_lock(&tok->lock);
250 WaitForSingleObject(tok->mutex, INFINITE);
252 if (acquire_sem(tok->sem) != B_NO_ERROR) {
259 tok->tid = find_thread(NULL);
266 * @tok: the simple mutex
271 xmlMutexUnlock(xmlMutexPtr tok)
273 if (tok == NULL)
277 pthread_mutex_unlock(&tok->lock);
279 ReleaseMutex(tok->mutex);
281 if (tok->tid == find_thread(NULL)) {
282 tok->tid = -1;
283 release_sem(tok->sem);
301 xmlRMutexPtr tok;
303 if ((tok = malloc(sizeof(xmlRMutex))) == NULL)
307 pthread_mutex_init(&tok->lock, NULL);
308 tok->held = 0;
309 tok->waiters = 0;
310 pthread_cond_init(&tok->cv, NULL);
313 InitializeCriticalSection(&tok->cs);
314 tok->count = 0;
316 if ((tok->lock = xmlNewMutex()) == NULL) {
317 free(tok);
320 tok->count = 0;
322 return (tok);
327 * @tok: the reentrant mutex
333 xmlFreeRMutex(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
335 if (tok == NULL)
339 pthread_mutex_destroy(&tok->lock);
340 pthread_cond_destroy(&tok->cv);
343 DeleteCriticalSection(&tok->cs);
345 xmlFreeMutex(tok->lock);
347 free(tok);
352 * @tok: the reentrant mutex
357 xmlRMutexLock(xmlRMutexPtr tok)
359 if (tok == NULL)
365 pthread_mutex_lock(&tok->lock);
366 if (tok->held) {
367 if (pthread_equal(tok->tid, pthread_self())) {
368 tok->held++;
369 pthread_mutex_unlock(&tok->lock);
372 tok->waiters++;
373 while (tok->held)
374 pthread_cond_wait(&tok->cv, &tok->lock);
375 tok->waiters--;
378 tok->tid = pthread_self();
379 tok->held = 1;
380 pthread_mutex_unlock(&tok->lock);
382 EnterCriticalSection(&tok->cs);
383 ++tok->count;
385 if (tok->lock->tid == find_thread(NULL)) {
386 tok->count++;
389 xmlMutexLock(tok->lock);
390 tok->count = 1;
397 * @tok: the reentrant mutex
402 xmlRMutexUnlock(xmlRMutexPtr tok ATTRIBUTE_UNUSED)
404 if (tok == NULL)
410 pthread_mutex_lock(&tok->lock);
411 tok->held--;
412 if (tok->held == 0) {
413 if (tok->waiters)
414 pthread_cond_signal(&tok->cv);
415 tok->tid = 0;
417 pthread_mutex_unlock(&tok->lock);
419 if (!--tok->count)
420 LeaveCriticalSection(&tok->cs);
422 if (tok->lock->tid == find_thread(NULL)) {
423 tok->count--;
424 if (tok->count == 0) {
425 xmlMutexUnlock(tok->lock);