Skip to content

Commit 9172c0c

Browse files
committed
py/modthread: Call mp_thread_start/mp_thread_finish around threads.
So the underlying thread implementation can do any necessary bookkeeping.
1 parent 722cff5 commit 9172c0c

2 files changed

Lines changed: 8 additions & 0 deletions

File tree

py/modthread.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,9 @@ STATIC void *thread_entry(void *args_in) {
154154
mp_stack_set_top(&ts + 1); // need to include ts in root-pointer scan
155155
mp_stack_set_limit(16 * 1024); // fixed stack limit for now
156156

157+
// signal that we are set up and running
158+
mp_thread_start();
159+
157160
// TODO set more thread-specific state here:
158161
// mp_pending_exception? (root pointer)
159162
// cur_exception (root pointer)
@@ -182,6 +185,9 @@ STATIC void *thread_entry(void *args_in) {
182185

183186
DEBUG_printf("[thread] finish ts=%p\n", &ts);
184187

188+
// signal that we are finished
189+
mp_thread_finish();
190+
185191
return NULL;
186192
}
187193

py/mpthread.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@ struct _mp_state_thread_t;
4141
struct _mp_state_thread_t *mp_thread_get_state(void);
4242
void mp_thread_set_state(void *state);
4343
void mp_thread_create(void *(*entry)(void*), void *arg, size_t stack_size);
44+
void mp_thread_start(void);
45+
void mp_thread_finish(void);
4446
void mp_thread_mutex_init(mp_thread_mutex_t *mutex);
4547
int mp_thread_mutex_lock(mp_thread_mutex_t *mutex, int wait);
4648
void mp_thread_mutex_unlock(mp_thread_mutex_t *mutex);

0 commit comments

Comments
 (0)