37 #if MICROPY_DEBUG_VERBOSE // print debugging info 38 #define DEBUG_PRINT (1) 39 #define DEBUG_printf DEBUG_printf 40 #else // don't print debugging info 41 #define DEBUG_PRINT (0) 42 #define DEBUG_printf(...) (void)0 50 typedef struct _mp_obj_thread_lock_t {
52 mp_thread_mutex_t mutex;
54 } mp_obj_thread_lock_t;
56 STATIC mp_obj_thread_lock_t *mp_obj_new_thread_lock(
void) {
57 mp_obj_thread_lock_t *
self =
m_new_obj(mp_obj_thread_lock_t);
58 self->base.type = &mp_type_thread_lock;
59 mp_thread_mutex_init(&self->mutex);
72 int ret = mp_thread_mutex_lock(&self->mutex, wait);
76 }
else if (ret == 1) {
92 mp_thread_mutex_unlock(&self->mutex);
100 return mp_obj_new_bool(self->locked);
106 return thread_lock_release(
args[0]);
122 .
name = MP_QSTR_lock,
129 STATIC size_t thread_stack_size = 0;
139 thread_stack_size = 0;
147 typedef struct _thread_entry_args_t {
155 } thread_entry_args_t;
157 STATIC void *thread_entry(
void *args_in) {
160 thread_entry_args_t *
args = (thread_entry_args_t*)args_in;
163 mp_thread_set_state(&ts);
169 mp_locals_set(
args->dict_locals);
170 mp_globals_set(
args->dict_globals);
217 thread_entry_args_t *th_args;
236 th_args->n_kw = map->
used;
238 for (
size_t i = 0, n = pos_args_len; i < map->
alloc; ++i) {
239 if (MP_MAP_SLOT_IS_FILLED(map, i)) {
240 th_args->args[n++] = map->
table[i].
key;
247 th_args->n_args = pos_args_len;
248 memcpy(th_args->args, pos_args_items, pos_args_len *
sizeof(
mp_obj_t));
251 th_args->dict_locals = mp_locals_get();
252 th_args->dict_globals = mp_globals_get();
255 th_args->stack_size = thread_stack_size;
258 th_args->fun =
args[0];
261 mp_thread_create(thread_entry, th_args, &th_args->stack_size);
294 #endif // MICROPY_PY_THREAD #define MICROPY_ERROR_PRINTER
NORETURN void mp_raise_msg(const mp_obj_type_t *exc_type, const char *msg)
const mp_obj_type_t mp_type_SystemExit
int DEBUG_printf(const char *fmt,...)
#define MP_DEFINE_CONST_DICT(dict_name, table_name)
mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type)
mp_obj_type_t * mp_obj_get_type(mp_const_obj_t o_in)
#define MP_OBJ_FROM_PTR(p)
#define MP_STATE_THREAD(x)
mp_int_t mp_obj_get_int(mp_const_obj_t arg)
bool mp_obj_is_subclass_fast(mp_const_obj_t object, mp_const_obj_t classinfo)
void mp_obj_get_array(mp_obj_t o, size_t *len, mp_obj_t **items)
#define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name)
#define m_new_obj_var(obj_type, var_type, var_num)
#define mp_stack_set_limit(limit)
NORETURN void mp_raise_OSError(int errno_)
void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind)
mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value)
#define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name)
const mp_obj_module_t mp_module_thread
const mp_obj_type_t mp_type_type
#define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name)
const mp_obj_type_t mp_type_dict
#define MP_THREAD_GIL_EXIT()
const mp_obj_type_t mp_type_module
#define MP_THREAD_GIL_ENTER()
int mp_printf(const mp_print_t *print, const char *fmt,...)
mp_obj_t mp_call_function_n_kw(mp_obj_t fun_in, size_t n_args, size_t n_kw, const mp_obj_t *args)
NORETURN void mp_raise_TypeError(const char *msg)
void mp_stack_set_top(void *top)
void * memcpy(void *dst, const void *src, size_t n)
const mp_obj_type_t mp_type_RuntimeError
void mp_obj_print_exception(const mp_print_t *print, mp_obj_t exc)