Igor Sysoev | d90282d | 2004-09-28 08:34:51 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
Igor Sysoev | ff8da91 | 2004-09-29 16:00:49 +0000 | [diff] [blame] | 3 | * Copyright (C) Igor Sysoev |
Maxim Konovalov | f8d59e3 | 2012-01-18 15:07:43 +0000 | [diff] [blame] | 4 | * Copyright (C) Nginx, Inc. |
Igor Sysoev | d90282d | 2004-09-28 08:34:51 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 8 | #ifndef _NGX_THREAD_H_INCLUDED_ |
| 9 | #define _NGX_THREAD_H_INCLUDED_ |
| 10 | |
| 11 | |
| 12 | #include <ngx_config.h> |
| 13 | #include <ngx_core.h> |
| 14 | |
| 15 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 16 | typedef HANDLE ngx_tid_t; |
| 17 | typedef DWORD ngx_tls_key_t; |
Igor Sysoev | c2068d0 | 2005-10-19 12:33:58 +0000 | [diff] [blame] | 18 | typedef DWORD ngx_thread_value_t; |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 19 | |
| 20 | |
| 21 | typedef struct { |
| 22 | HANDLE mutex; |
| 23 | ngx_log_t *log; |
| 24 | } ngx_mutex_t; |
| 25 | |
| 26 | |
Igor Sysoev | c2068d0 | 2005-10-19 12:33:58 +0000 | [diff] [blame] | 27 | ngx_err_t ngx_create_thread(ngx_tid_t *tid, |
| 28 | ngx_thread_value_t (__stdcall *func)(void *arg), void *arg, ngx_log_t *log); |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 29 | ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle); |
| 30 | |
| 31 | ngx_err_t ngx_thread_key_create(ngx_tls_key_t *key); |
| 32 | #define ngx_thread_key_create_n "TlsAlloc()" |
| 33 | ngx_err_t ngx_thread_set_tls(ngx_tls_key_t *key, void *data); |
| 34 | #define ngx_thread_set_tls_n "TlsSetValue()" |
| 35 | #define ngx_thread_get_tls TlsGetValue |
| 36 | |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 37 | |
| 38 | #define ngx_thread_volatile volatile |
| 39 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 40 | #define ngx_log_tid GetCurrentThreadId() |
| 41 | #define NGX_TID_T_FMT "%ud" |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 42 | |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 43 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 44 | ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags); |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 45 | |
Igor Sysoev | c2068d0 | 2005-10-19 12:33:58 +0000 | [diff] [blame] | 46 | void ngx_mutex_lock(ngx_mutex_t *m); |
Igor Sysoev | c157172 | 2005-03-19 12:38:37 +0000 | [diff] [blame] | 47 | ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m); |
Igor Sysoev | c2068d0 | 2005-10-19 12:33:58 +0000 | [diff] [blame] | 48 | void ngx_mutex_unlock(ngx_mutex_t *m); |
Igor Sysoev | c157172 | 2005-03-19 12:38:37 +0000 | [diff] [blame] | 49 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 50 | |
| 51 | /* STUB */ |
| 52 | #define NGX_MUTEX_LIGHT 0 |
Igor Sysoev | c157172 | 2005-03-19 12:38:37 +0000 | [diff] [blame] | 53 | /**/ |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 54 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 55 | |
| 56 | extern ngx_int_t ngx_threads_n; |
Igor Sysoev | a536298 | 2004-03-04 07:04:55 +0000 | [diff] [blame] | 57 | |
| 58 | |
| 59 | #endif /* _NGX_THREAD_H_INCLUDED_ */ |