blob: c23c809ffad617e3e2ca3e83bed2a1b19cc52eb7 [file] [log] [blame]
Igor Sysoevd90282d2004-09-28 08:34:51 +00001
2/*
Igor Sysoevff8da912004-09-29 16:00:49 +00003 * Copyright (C) Igor Sysoev
Maxim Konovalovf8d59e32012-01-18 15:07:43 +00004 * Copyright (C) Nginx, Inc.
Igor Sysoevd90282d2004-09-28 08:34:51 +00005 */
6
7
Igor Sysoeva5362982004-03-04 07:04:55 +00008#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 Sysoev1b735832004-11-11 14:07:14 +000016typedef HANDLE ngx_tid_t;
17typedef DWORD ngx_tls_key_t;
Igor Sysoevc2068d02005-10-19 12:33:58 +000018typedef DWORD ngx_thread_value_t;
Igor Sysoev1b735832004-11-11 14:07:14 +000019
20
21typedef struct {
22 HANDLE mutex;
23 ngx_log_t *log;
24} ngx_mutex_t;
25
26
Igor Sysoevc2068d02005-10-19 12:33:58 +000027ngx_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 Sysoev1b735832004-11-11 14:07:14 +000029ngx_int_t ngx_init_threads(int n, size_t size, ngx_cycle_t *cycle);
30
31ngx_err_t ngx_thread_key_create(ngx_tls_key_t *key);
32#define ngx_thread_key_create_n "TlsAlloc()"
33ngx_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 Sysoeva5362982004-03-04 07:04:55 +000037
38#define ngx_thread_volatile volatile
39
Igor Sysoev1b735832004-11-11 14:07:14 +000040#define ngx_log_tid GetCurrentThreadId()
41#define NGX_TID_T_FMT "%ud"
Igor Sysoeva5362982004-03-04 07:04:55 +000042
Igor Sysoeva5362982004-03-04 07:04:55 +000043
Igor Sysoev1b735832004-11-11 14:07:14 +000044ngx_mutex_t *ngx_mutex_init(ngx_log_t *log, ngx_uint_t flags);
Igor Sysoeva5362982004-03-04 07:04:55 +000045
Igor Sysoevc2068d02005-10-19 12:33:58 +000046void ngx_mutex_lock(ngx_mutex_t *m);
Igor Sysoevc1571722005-03-19 12:38:37 +000047ngx_int_t ngx_mutex_trylock(ngx_mutex_t *m);
Igor Sysoevc2068d02005-10-19 12:33:58 +000048void ngx_mutex_unlock(ngx_mutex_t *m);
Igor Sysoevc1571722005-03-19 12:38:37 +000049
Igor Sysoev1b735832004-11-11 14:07:14 +000050
51/* STUB */
52#define NGX_MUTEX_LIGHT 0
Igor Sysoevc1571722005-03-19 12:38:37 +000053/**/
Igor Sysoeva5362982004-03-04 07:04:55 +000054
Igor Sysoev1b735832004-11-11 14:07:14 +000055
56extern ngx_int_t ngx_threads_n;
Igor Sysoeva5362982004-03-04 07:04:55 +000057
58
59#endif /* _NGX_THREAD_H_INCLUDED_ */