Mercurial > hg > nginx-quic
view src/event/ngx_event_spinlock.c @ 371:780e93985b93
nginx-0.0.7-2004-06-28-20:05:02 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Mon, 28 Jun 2004 16:05:02 +0000 |
parents | f2755a2885c8 |
children |
line wrap: on
line source
void _spinlock(ngx_atomic_t *lock) { ngx_int_t tries; tries = 0; for ( ;; ) { if (*lock) { if (ngx_ncpu > 1 && tries++ < 1000) { continue; } sched_yield(); tries = 0; } else { if (ngx_atomic_cmp_set(lock, 0, 1)) { return; } } } }