Mercurial > hg > nginx
comparison src/event/ngx_event_posted.c @ 376:d0451e402e27
nginx-0.0.7-2004-07-05-10:55:54 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 05 Jul 2004 06:55:54 +0000 |
parents | 744ccb59062d |
children | 41437e4fd9b4 |
comparison
equal
deleted
inserted
replaced
375:744ccb59062d | 376:d0451e402e27 |
---|---|
6 | 6 |
7 ngx_thread_volatile ngx_event_t *ngx_posted_events; | 7 ngx_thread_volatile ngx_event_t *ngx_posted_events; |
8 | 8 |
9 #if (NGX_THREADS) | 9 #if (NGX_THREADS) |
10 ngx_mutex_t *ngx_posted_events_mutex; | 10 ngx_mutex_t *ngx_posted_events_mutex; |
11 ngx_cond_t *ngx_posted_events_cv; | |
12 #endif | 11 #endif |
13 | 12 |
14 | 13 |
15 void ngx_event_process_posted(ngx_cycle_t *cycle) | 14 void ngx_event_process_posted(ngx_cycle_t *cycle) |
16 { | 15 { |
55 } | 54 } |
56 | 55 |
57 | 56 |
58 #if (NGX_THREADS) | 57 #if (NGX_THREADS) |
59 | 58 |
59 void ngx_wakeup_worker_thread(ngx_cycle_t *cycle) | |
60 { | |
61 ngx_int_t i; | |
62 | |
63 for (i = 0; i < ngx_threads_n; i++) { | |
64 if (ngx_threads[i].state == NGX_THREAD_FREE) { | |
65 ngx_cond_signal(ngx_threads[i].cv); | |
66 return; | |
67 } | |
68 } | |
69 } | |
70 | |
71 | |
60 ngx_int_t ngx_event_thread_process_posted(ngx_cycle_t *cycle) | 72 ngx_int_t ngx_event_thread_process_posted(ngx_cycle_t *cycle) |
61 { | 73 { |
62 ngx_event_t *ev; | 74 ngx_event_t *ev; |
63 | 75 |
64 for ( ;; ) { | 76 for ( ;; ) { |
69 | 81 |
70 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, | 82 ngx_log_debug1(NGX_LOG_DEBUG_EVENT, cycle->log, 0, |
71 "posted event " PTR_FMT, ev); | 83 "posted event " PTR_FMT, ev); |
72 | 84 |
73 if (ev == NULL) { | 85 if (ev == NULL) { |
74 ngx_mutex_unlock(ngx_posted_events_mutex); | |
75 return NGX_OK; | 86 return NGX_OK; |
76 } | 87 } |
77 | 88 |
78 if (ngx_trylock(ev->lock) == 0) { | 89 if (ngx_trylock(ev->lock) == 0) { |
79 | 90 |
142 break; | 153 break; |
143 } | 154 } |
144 } | 155 } |
145 } | 156 } |
146 | 157 |
158 #else | |
159 | |
160 void ngx_wakeup_worker_thread(ngx_cycle_t *cycle) | |
161 { | |
162 } | |
163 | |
147 #endif | 164 #endif |