Lines Matching defs:app_lock
164 LockPtr app_lock = app->lock_info;
167 xmutex_lock(app_lock->mutex);
168 app_lock->level++;
172 xmutex_lock(app_lock->mutex);
173 if (!xthread_have_id(app_lock->holder)) {
174 app_lock->holder = self;
175 assert(xthread_equal(app_lock->holder, self));
176 xmutex_unlock(app_lock->mutex);
179 if (xthread_equal(app_lock->holder, self)) {
180 app_lock->level++;
181 xmutex_unlock(app_lock->mutex);
184 while (xthread_have_id(app_lock->holder)) {
185 xcondition_wait(app_lock->cond, app_lock->mutex);
187 app_lock->holder = self;
188 assert(xthread_equal(app_lock->holder, self));
189 xmutex_unlock(app_lock->mutex);
196 LockPtr app_lock = app->lock_info;
199 app_lock->level--;
200 xmutex_unlock(app_lock->mutex);
207 xmutex_lock(app_lock->mutex);
208 assert(xthread_equal(app_lock->holder, self));
209 if (app_lock->level != 0) {
210 app_lock->level--;
211 xmutex_unlock(app_lock->mutex);
214 xthread_clear_id(app_lock->holder);
215 xcondition_signal(app_lock->cond);
216 xmutex_unlock(app_lock->mutex);
226 LockPtr app_lock = app->lock_info;
230 xmutex_lock(app_lock->mutex);
231 assert(xthread_equal(app_lock->holder, self));
233 *level = app_lock->level;
238 if (app_lock->stack.sp == (int) app_lock->stack.size - 1) {
241 app_lock->stack.st = (struct _Tstack *)
242 XtReallocArray(app_lock->stack.st,
243 (Cardinal) (app_lock->stack.size + STACK_INCR),
245 ii = app_lock->stack.size;
246 app_lock->stack.size += STACK_INCR;
247 for (; ii < app_lock->stack.size; ii++) {
248 app_lock->stack.st[ii].c = xcondition_malloc();
249 xcondition_init(app_lock->stack.st[ii].c);
252 app_lock->stack.st[++(app_lock->stack.sp)].t = self;
255 while (app_lock->level > 0) {
256 app_lock->level--;
257 xmutex_unlock(app_lock->mutex);
260 xcondition_signal(app_lock->cond);
261 app_lock->level = 0;
262 xthread_clear_id(app_lock->holder);
263 xmutex_unlock(app_lock->mutex);
270 LockPtr app_lock = app->lock_info;
273 xmutex_lock(app_lock->mutex);
275 app_lock->level++;
277 while (xthread_have_id(app_lock->holder)) {
278 xcondition_wait(app_lock->cond, app_lock->mutex);
281 if (!xthread_equal(app_lock->stack.st[app_lock->stack.sp].t, self)) {
284 for (ii = app_lock->stack.sp - 1; ii >= 0; ii--) {
285 if (xthread_equal(app_lock->stack.st[ii].t, self)) {
286 xcondition_wait(app_lock->stack.st[ii].c, app_lock->mutex);
291 while (xthread_have_id(app_lock->holder)) {
292 xcondition_wait(app_lock->cond, app_lock->mutex);
297 while (app_lock->level < level) {
298 xmutex_lock(app_lock->mutex);
299 app_lock->level++;
302 app_lock->holder = self;
303 app_lock->level = level;
304 assert(xthread_equal(app_lock->holder, self));
308 (app_lock->stack.sp)--;
309 if (app_lock->stack.sp >= 0) {
310 xcondition_signal(app_lock->stack.st[app_lock->stack.sp].c);
314 xmutex_unlock(app_lock->mutex);
322 LockPtr app_lock = app->lock_info;
324 if (app_lock) {
325 xmutex_clear(app_lock->mutex);
326 xmutex_free(app_lock->mutex);
328 xcondition_clear(app_lock->cond);
329 xcondition_free(app_lock->cond);
331 if (app_lock->stack.st != (struct _Tstack *) NULL) {
332 for (ii = 0; ii < app_lock->stack.size; ii++) {
333 xcondition_clear(app_lock->stack.st[ii].c);
334 xcondition_free(app_lock->stack.st[ii].c);
336 XtFree((char *) app_lock->stack.st);
338 XtFree((char *) app_lock);
347 LockPtr app_lock;
355 app_lock = app->lock_info = XtNew(LockRec);
356 app_lock->mutex = xmutex_malloc();
357 xmutex_init(app_lock->mutex);
358 app_lock->level = 0;
360 app_lock->cond = xcondition_malloc();
361 xcondition_init(app_lock->cond);
362 xthread_clear_id(app_lock->holder);
364 app_lock->stack.size = STACK_INCR;
365 app_lock->stack.sp = -1;
366 app_lock->stack.st = XtMallocArray(STACK_INCR, sizeof(struct _Tstack));
368 app_lock->stack.st[ii].c = xcondition_malloc();
369 xcondition_init(app_lock->stack.st[ii].c);