blob: c9b280f7c7420019f924f3f2befc696daf26dbc1 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
|
#include <u.h>
#include <libc.h>
#include "cocoa-thread.h"
#ifndef TRY_LIBTHREAD
static pthread_mutex_t initlock = PTHREAD_MUTEX_INITIALIZER;
void
qlock(QLock *q)
{
if(q->init == 0){
pthread_mutex_lock(&initlock);
if(q->init == 0){
pthread_mutex_init(&q->m, nil);
q->init = 1;
}
pthread_mutex_unlock(&initlock);
}
pthread_mutex_lock(&q->m);
}
void
qunlock(QLock *q)
{
pthread_mutex_unlock(&q->m);
}
#endif
|