Lines Matching defs:lock

179 /* A pthread mutex isn't sufficient to model the Python lock type
182 * -> a thread tries to lock a mutex it already has locked
188 * The pthread_lock struct implements a Python lock as a "locked?" bit
196 /* a <cond, mutex> pair to handle an acquire of a locked lock */
378 sem_t *lock;
385 lock = (sem_t *)PyMem_RawMalloc(sizeof(sem_t));
387 if (lock) {
388 status = sem_init(lock,0,1);
392 PyMem_RawFree((void *)lock);
393 lock = NULL;
397 dprintf(("PyThread_allocate_lock() -> %p\n", (void *)lock));
398 return (PyThread_type_lock)lock;
402 PyThread_free_lock(PyThread_type_lock lock)
404 sem_t *thelock = (sem_t *)lock;
408 dprintf(("PyThread_free_lock(%p) called\n", lock));
432 PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
436 sem_t *thelock = (sem_t *)lock;
441 lock, microseconds, intr_flag));
550 lock, microseconds, intr_flag, success));
555 PyThread_release_lock(PyThread_type_lock lock)
557 sem_t *thelock = (sem_t *)lock;
561 dprintf(("PyThread_release_lock(%p) called\n", lock));
575 pthread_lock *lock;
582 lock = (pthread_lock *) PyMem_RawCalloc(1, sizeof(pthread_lock));
583 if (lock) {
584 lock->locked = 0;
586 status = pthread_mutex_init(&lock->mut, NULL);
593 _Py_ANNOTATE_PURE_HAPPENS_BEFORE_MUTEX(&lock->mut);
595 status = _PyThread_cond_init(&lock->lock_released);
599 PyMem_RawFree((void *)lock);
600 lock = 0;
604 dprintf(("PyThread_allocate_lock() -> %p\n", (void *)lock));
605 return (PyThread_type_lock) lock;
609 PyThread_free_lock(PyThread_type_lock lock)
611 pthread_lock *thelock = (pthread_lock *)lock;
615 dprintf(("PyThread_free_lock(%p) called\n", lock));
630 PyThread_acquire_lock_timed(PyThread_type_lock lock, PY_TIMEOUT_T microseconds,
634 pthread_lock *thelock = (pthread_lock *)lock;
638 lock, microseconds, intr_flag));
658 /* continue trying until we get the lock */
682 /* We were woken up, but didn't get the lock. We probably received
700 lock, microseconds, intr_flag, success));
705 PyThread_release_lock(PyThread_type_lock lock)
707 pthread_lock *thelock = (pthread_lock *)lock;
711 dprintf(("PyThread_release_lock(%p) called\n", lock));
718 /* wake up someone (anyone, if any) waiting on the lock */
729 _PyThread_at_fork_reinit(PyThread_type_lock *lock)
736 /* bpo-6721, bpo-40089: The old lock can be in an inconsistent state.
737 fork() can be called in the middle of an operation on the lock done by
738 another thread. So don't call PyThread_free_lock(*lock).
744 *lock = new_lock;
749 PyThread_acquire_lock(PyThread_type_lock lock, int waitflag)
751 return PyThread_acquire_lock_timed(lock, waitflag ? -1 : 0, /*intr_flag=*/0);