diff --git a/include/uv.h b/include/uv.h index 4078bcd8..6a763839 100644 --- a/include/uv.h +++ b/include/uv.h @@ -1789,6 +1789,7 @@ UV_EXTERN void uv_once(uv_once_t* guard, void (*callback)(void)); UV_EXTERN int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg); +UV_EXTERN unsigned long uv_thread_self(void); UV_EXTERN int uv_thread_join(uv_thread_t *tid); /* the presence of these unions force similar struct layout */ diff --git a/src/uv-common.c b/src/uv-common.c index 75dfcd89..dd91dbb2 100644 --- a/src/uv-common.c +++ b/src/uv-common.c @@ -314,6 +314,15 @@ int uv_thread_create(uv_thread_t *tid, void (*entry)(void *arg), void *arg) { } +unsigned long uv_thread_self(void) { +#ifdef _WIN32 + return (unsigned long) GetCurrentThreadId(); +#else + return (unsigned long) pthread_self(); +#endif +} + + void uv_walk(uv_loop_t* loop, uv_walk_cb walk_cb, void* arg) { ngx_queue_t* q; uv_handle_t* h;