comparison src/os/unix/ngx_thread.h @ 6018:466bd63b63d1

Thread pools implementation.
author Valentin Bartenev <vbart@nginx.com>
date Sat, 14 Mar 2015 17:37:07 +0300
parents 457ec43dd8d5
children fa77496b1df2
comparison
equal deleted inserted replaced
6017:83d54192e97b 6018:466bd63b63d1
109 109
110 #else /* !NGX_OLD_THREADS */ 110 #else /* !NGX_OLD_THREADS */
111 111
112 #define ngx_thread_volatile 112 #define ngx_thread_volatile
113 113
114 #if (NGX_THREADS)
115
116 #include <pthread.h>
117
118
119 typedef pthread_mutex_t ngx_thread_mutex_t;
120
121 ngx_int_t ngx_thread_mutex_create(ngx_thread_mutex_t *mtx, ngx_log_t *log);
122 ngx_int_t ngx_thread_mutex_destroy(ngx_thread_mutex_t *mtx, ngx_log_t *log);
123 ngx_int_t ngx_thread_mutex_lock(ngx_thread_mutex_t *mtx, ngx_log_t *log);
124 ngx_int_t ngx_thread_mutex_unlock(ngx_thread_mutex_t *mtx, ngx_log_t *log);
125
126
127 typedef pthread_cond_t ngx_thread_cond_t;
128
129 ngx_int_t ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log);
130 ngx_int_t ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log);
131 ngx_int_t ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log);
132 ngx_int_t ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx,
133 ngx_log_t *log);
134
135
136 #if (NGX_LINUX)
137
138 typedef pid_t ngx_tid_t;
139 #define NGX_TID_T_FMT "%P"
140
141 #elif (NGX_FREEBSD)
142
143 typedef uint32_t ngx_tid_t;
144 #define NGX_TID_T_FMT "%uD"
145
146 #elif (NGX_DARWIN)
147
148 typedef uint64_t ngx_tid_t;
149 #define NGX_TID_T_FMT "%uA"
150
151 #else
152
153 typedef uint64_t ngx_tid_t;
154 #define NGX_TID_T_FMT "%uA"
155
156 #endif
157
158 ngx_tid_t ngx_thread_tid(void);
159
160 #define ngx_log_tid ngx_thread_tid()
161
162 #else
163
114 #define ngx_log_tid 0 164 #define ngx_log_tid 0
115 #define NGX_TID_T_FMT "%d" 165 #define NGX_TID_T_FMT "%d"
166
167 #endif
116 168
117 #define ngx_mutex_trylock(m) NGX_OK 169 #define ngx_mutex_trylock(m) NGX_OK
118 #define ngx_mutex_lock(m) 170 #define ngx_mutex_lock(m)
119 #define ngx_mutex_unlock(m) 171 #define ngx_mutex_unlock(m)
120 172