| |
| |
| |
| |
| |
| |
|
|
| #pragma once |
|
|
| #include <pthread.h> |
| #include <stdbool.h> |
|
|
| |
| |
| |
|
|
| #ifdef THREADING_DEBUG |
| #define DBG(format, ...) emscripten_dbgf(format, ##__VA_ARGS__) |
| #else |
| #define DBG(format, ...) |
| #endif |
|
|
| #define EM_THREAD_NAME_MAX 32 |
|
|
| #define EM_THREAD_STATUS int |
| #define EM_THREAD_STATUS_NOTSTARTED 0 |
| #define EM_THREAD_STATUS_RUNNING 1 |
| #define EM_THREAD_STATUS_SLEEPING 2 |
| #define EM_THREAD_STATUS_WAITFUTEX 3 |
| #define EM_THREAD_STATUS_WAITMUTEX 4 |
| #define EM_THREAD_STATUS_WAITPROXY 5 |
| #define EM_THREAD_STATUS_FINISHED 6 |
| #define EM_THREAD_STATUS_NUMFIELDS 7 |
|
|
| typedef struct thread_profiler_block { |
| |
| _Atomic int threadStatus; |
| |
| double currentStatusStartTime; |
| |
| |
| double timeSpentInStatus[EM_THREAD_STATUS_NUMFIELDS]; |
| |
| char name[EM_THREAD_NAME_MAX]; |
| } thread_profiler_block; |
|
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| bool _emscripten_yield(double now); |
|
|
| void _emscripten_init_main_thread_js(void* tb); |
| void _emscripten_thread_profiler_enable(); |
| void _emscripten_thread_cleanup(pthread_t thread); |
|
|
| hidden void* _emscripten_tls_init(void); |
| hidden void _emscripten_tls_free(void); |
|
|
| |
| |
| |
| |
| |
| |
| |
| void _emscripten_thread_set_strongref(pthread_t thread); |
|
|
| |
| |
| |
| |
| int _emscripten_thread_is_valid(pthread_t thread); |
|
|
| void _emscripten_thread_exit_joinable(pthread_t thread); |
| void _emscripten_thread_exit(void* result); |
| void _emscripten_process_dlopen_queue(void); |
|
|
| #if !defined(__EMSCRIPTEN_PTHREADS__) || defined(NDEBUG) |
| #define emscripten_set_current_thread_status(newStatus) |
| #define emscripten_conditional_set_current_thread_status(expectedStatus, newStatus) |
| #else |
| |
| void _emscripten_thread_profiler_init(pthread_t thread); |
|
|
| |
| |
| |
| |
| |
| void emscripten_set_current_thread_status(EM_THREAD_STATUS newStatus); |
|
|
| |
| |
| |
| |
| |
| void emscripten_conditional_set_current_thread_status(EM_THREAD_STATUS expectedStatus, EM_THREAD_STATUS newStatus); |
| #endif |
|
|
| int __pthread_kill_js(pthread_t t, int sig); |
| int __pthread_create_js(struct __pthread *thread, const pthread_attr_t *attr, void *(*start_routine) (void *), void *arg); |
| int _emscripten_default_pthread_stack_size(); |
| void __set_thread_state(pthread_t ptr, int is_main, int is_runtime, int can_block); |
|
|
| double _emscripten_receive_on_main_thread_js(int funcIndex, void* emAsmAddr, pthread_t callingThread, int numCallArgs, double* args, void* ctx, void* ctxArgs); |
|
|
| void _emscripten_run_js_on_main_thread_done(void* ctx, void* arg, double result); |
|
|
| |
| |
| |
| int _emscripten_thread_supports_atomics_wait(void); |
|
|
| pid_t _emscripten_get_next_tid(); |
|
|
| |
| |
| |
| |
| void _emscripten_thread_notify(pthread_t thread); |
|
|