Mercurial > hg > nginx
diff src/core/ngx_spinlock.c @ 373:018569a8f09c
nginx-0.0.7-2004-06-30-19:30:41 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 30 Jun 2004 15:30:41 +0000 |
parents | src/event/ngx_event_spinlock.c@f2755a2885c8 |
children | 5cdc4838d4e8 |
line wrap: on
line diff
copy from src/event/ngx_event_spinlock.c copy to src/core/ngx_spinlock.c --- a/src/event/ngx_event_spinlock.c +++ b/src/core/ngx_spinlock.c @@ -1,19 +1,23 @@ + +#include <ngx_config.h> +#include <ngx_core.h> -void _spinlock(ngx_atomic_t *lock) +void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin) { - ngx_int_t tries; + ngx_uint_t tries; tries = 0; for ( ;; ) { if (*lock) { - if (ngx_ncpu > 1 && tries++ < 1000) { + if (ngx_ncpu > 1 && tries++ < spin) { continue; } - sched_yield(); + ngx_sched_yield(); + tries = 0; } else { @@ -23,4 +27,3 @@ void _spinlock(ngx_atomic_t *lock) } } } -