diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-06-21 23:22:53 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-06-21 23:22:53 +0400 |
commit | b14169a714bb3deeb7f4912a58238f7a54aeecd1 (patch) | |
tree | 6f1cd4f91e2239d74e8075cbc7fb965d8d93cb49 /src/event | |
parent | ef06648615d6ce6e000e6c737f80c2ba9fa04d3a (diff) |
nginx-0.0.7-2004-06-21-23:22:53 import
Diffstat (limited to 'src/event')
-rw-r--r-- | src/event/ngx_event_spinlock.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/event/ngx_event_spinlock.c b/src/event/ngx_event_spinlock.c new file mode 100644 index 000000000..58edb2af5 --- /dev/null +++ b/src/event/ngx_event_spinlock.c @@ -0,0 +1,26 @@ + + +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; + } + } + } +} + |