diff options
author | David Lechner <david@pybricks.com> | 2023-08-03 15:20:30 -0500 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2023-09-03 18:49:18 +1000 |
commit | ffb43b2dd37f10f48612d369b5cad9731c2a0597 (patch) | |
tree | cecc29542135b957063038985bdb466e3b05ddae /py/mpthread.h | |
parent | c0d4c604e6a140c0f2967e1b43fd94d0b029c73f (diff) |
py/modthread: Return thread id from start_new_thread().
In CPython, `_thread.start_new_thread()` returns an ID that is the same ID
that is returned by `_thread.get_ident()`. The current MicroPython
implementation of `_thread.start_new_thread()` always returns `None`.
This modifies the required functions to return a value. The native thread
id is returned since this can be used for interop with other functions, for
example, `pthread_kill()` on *nix. `_thread.get_ident()` is also modified
to return the native thread id so that the values match and avoids the need
for a separate `native_id` attribute.
Fixes issue #12153.
Signed-off-by: David Lechner <david@pybricks.com>
Diffstat (limited to 'py/mpthread.h')
-rw-r--r-- | py/mpthread.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/py/mpthread.h b/py/mpthread.h index e611ef4c1..f335cc029 100644 --- a/py/mpthread.h +++ b/py/mpthread.h @@ -40,7 +40,8 @@ struct _mp_state_thread_t; struct _mp_state_thread_t *mp_thread_get_state(void); void mp_thread_set_state(struct _mp_state_thread_t *state); -void mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size); +mp_uint_t mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size); +mp_uint_t mp_thread_get_id(void); void mp_thread_start(void); void mp_thread_finish(void); void mp_thread_mutex_init(mp_thread_mutex_t *mutex); |