diff options
author | David Lechner <david@pybricks.com> | 2020-01-22 11:19:37 -0600 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-01-23 13:29:11 +1100 |
commit | edbb73a411919af954619dcee02bc448912c9e27 (patch) | |
tree | b868fbd83601252ef3a7d43e6ad0ce155740355b /py | |
parent | ccc18f047d6669583cdf8ddd53ec41d026743a25 (diff) |
py/qstr: Don't include or init qstr_mutex when GIL is enabled.
When threads and the GIL are enabled, then the qstr mutex is not needed.
The qstr_mutex field is never used in this case because of:
#if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
#define QSTR_ENTER() mp_thread_mutex_lock(&MP_STATE_VM(qstr_mutex), 1)
#define QSTR_EXIT() mp_thread_mutex_unlock(&MP_STATE_VM(qstr_mutex))
#else
#define QSTR_ENTER()
#define QSTR_EXIT()
#endif
So, we can completely remove qstr_mutex everywhere when MICROPY_PY_THREAD
&& !MICROPY_PY_THREAD_GIL.
Diffstat (limited to 'py')
-rw-r--r-- | py/mpstate.h | 2 | ||||
-rw-r--r-- | py/qstr.c | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/py/mpstate.h b/py/mpstate.h index 9bb87f0ba..5f6cf5593 100644 --- a/py/mpstate.h +++ b/py/mpstate.h @@ -203,7 +203,7 @@ typedef struct _mp_state_vm_t { size_t qstr_last_alloc; size_t qstr_last_used; - #if MICROPY_PY_THREAD + #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL // This is a global mutex used to make qstr interning thread-safe. mp_thread_mutex_t qstr_mutex; #endif @@ -125,7 +125,7 @@ void qstr_init(void) { MP_STATE_VM(last_pool) = (qstr_pool_t*)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left MP_STATE_VM(qstr_last_chunk) = NULL; - #if MICROPY_PY_THREAD + #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL mp_thread_mutex_init(&MP_STATE_VM(qstr_mutex)); #endif } |