Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 27 additions & 4 deletions Modules/_multiprocessing/clinic/semaphore.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 10 additions & 5 deletions Modules/_multiprocessing/semaphore.c
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ _GetSemaphoreValue(HANDLE handle, long *value)
}

/*[clinic input]
@critical_section
_multiprocessing.SemLock.acquire

block as blocking: bool = True
Expand All @@ -92,7 +93,7 @@ Acquire the semaphore/lock.
static PyObject *
_multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
PyObject *timeout_obj)
/*[clinic end generated code: output=f9998f0b6b0b0872 input=e5b45f5cbb775166]*/
/*[clinic end generated code: output=f9998f0b6b0b0872 input=079ca779975f3ad6]*/
{
double timeout;
DWORD res, full_msecs, nhandles;
Expand Down Expand Up @@ -172,14 +173,15 @@ _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
}

/*[clinic input]
@critical_section
_multiprocessing.SemLock.release

Release the semaphore/lock.
[clinic start generated code]*/

static PyObject *
_multiprocessing_SemLock_release_impl(SemLockObject *self)
/*[clinic end generated code: output=b22f53ba96b0d1db input=ba7e63a961885d3d]*/
/*[clinic end generated code: output=b22f53ba96b0d1db input=9bd62d3645e7a531]*/
{
if (self->kind == RECURSIVE_MUTEX) {
if (!ISMINE(self)) {
Expand Down Expand Up @@ -297,6 +299,7 @@ sem_timedwait_save(sem_t *sem, struct timespec *deadline, PyThreadState *_save)
#endif /* !HAVE_SEM_TIMEDWAIT */

/*[clinic input]
@critical_section
_multiprocessing.SemLock.acquire

block as blocking: bool = True
Expand All @@ -308,7 +311,7 @@ Acquire the semaphore/lock.
static PyObject *
_multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
PyObject *timeout_obj)
/*[clinic end generated code: output=f9998f0b6b0b0872 input=e5b45f5cbb775166]*/
/*[clinic end generated code: output=f9998f0b6b0b0872 input=079ca779975f3ad6]*/
{
int res, err = 0;
struct timespec deadline = {0};
Expand Down Expand Up @@ -382,14 +385,15 @@ _multiprocessing_SemLock_acquire_impl(SemLockObject *self, int blocking,
}

/*[clinic input]
@critical_section
_multiprocessing.SemLock.release

Release the semaphore/lock.
[clinic start generated code]*/

static PyObject *
_multiprocessing_SemLock_release_impl(SemLockObject *self)
/*[clinic end generated code: output=b22f53ba96b0d1db input=ba7e63a961885d3d]*/
/*[clinic end generated code: output=b22f53ba96b0d1db input=9bd62d3645e7a531]*/
{
if (self->kind == RECURSIVE_MUTEX) {
if (!ISMINE(self)) {
Expand Down Expand Up @@ -583,14 +587,15 @@ semlock_dealloc(SemLockObject* self)
}

/*[clinic input]
@critical_section
_multiprocessing.SemLock._count

Num of `acquire()`s minus num of `release()`s for this process.
[clinic start generated code]*/

static PyObject *
_multiprocessing_SemLock__count_impl(SemLockObject *self)
/*[clinic end generated code: output=5ba8213900e517bb input=36fc59b1cd1025ab]*/
/*[clinic end generated code: output=5ba8213900e517bb input=9fa6e0b321b16935]*/
{
return PyLong_FromLong((long)self->count);
}
Expand Down