# include "pycore_gc.h" // PyGC_Head
# include "pycore_runtime.h" // _Py_ID()
#endif
+#include "pycore_critical_section.h"// Py_BEGIN_CRITICAL_SECTION()
#include "pycore_modsupport.h" // _PyArg_UnpackKeywords()
#if defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS)
}
timeout_obj = args[1];
skip_optional_pos:
+ Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock_acquire_impl(self, blocking, timeout_obj);
+ Py_END_CRITICAL_SECTION();
exit:
return return_value;
static PyObject *
_multiprocessing_SemLock_release(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
- return _multiprocessing_SemLock_release_impl(self);
+ PyObject *return_value = NULL;
+
+ Py_BEGIN_CRITICAL_SECTION(self);
+ return_value = _multiprocessing_SemLock_release_impl(self);
+ Py_END_CRITICAL_SECTION();
+
+ return return_value;
}
#endif /* defined(HAVE_MP_SEMAPHORE) && defined(MS_WINDOWS) */
}
timeout_obj = args[1];
skip_optional_pos:
+ Py_BEGIN_CRITICAL_SECTION(self);
return_value = _multiprocessing_SemLock_acquire_impl(self, blocking, timeout_obj);
+ Py_END_CRITICAL_SECTION();
exit:
return return_value;
static PyObject *
_multiprocessing_SemLock_release(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
- return _multiprocessing_SemLock_release_impl(self);
+ PyObject *return_value = NULL;
+
+ Py_BEGIN_CRITICAL_SECTION(self);
+ return_value = _multiprocessing_SemLock_release_impl(self);
+ Py_END_CRITICAL_SECTION();
+
+ return return_value;
}
#endif /* defined(HAVE_MP_SEMAPHORE) && !defined(MS_WINDOWS) */
static PyObject *
_multiprocessing_SemLock__count(SemLockObject *self, PyObject *Py_UNUSED(ignored))
{
- return _multiprocessing_SemLock__count_impl(self);
+ PyObject *return_value = NULL;
+
+ Py_BEGIN_CRITICAL_SECTION(self);
+ return_value = _multiprocessing_SemLock__count_impl(self);
+ Py_END_CRITICAL_SECTION();
+
+ return return_value;
}
#endif /* defined(HAVE_MP_SEMAPHORE) */
#ifndef _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
#define _MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF
#endif /* !defined(_MULTIPROCESSING_SEMLOCK___EXIT___METHODDEF) */
-/*[clinic end generated code: output=d57992037e6770b6 input=a9049054013a1b77]*/
+/*[clinic end generated code: output=713b597256233716 input=a9049054013a1b77]*/
}
/*[clinic input]
+@critical_section
_multiprocessing.SemLock.acquire
block as blocking: bool = True
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;
}
/*[clinic input]
+@critical_section
_multiprocessing.SemLock.release
Release the semaphore/lock.
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)) {
#endif /* !HAVE_SEM_TIMEDWAIT */
/*[clinic input]
+@critical_section
_multiprocessing.SemLock.acquire
block as blocking: bool = True
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};
}
/*[clinic input]
+@critical_section
_multiprocessing.SemLock.release
Release the semaphore/lock.
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)) {
}
/*[clinic input]
+@critical_section
_multiprocessing.SemLock._count
Num of `acquire()`s minus num of `release()`s for this process.
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);
}