Mercurial > hg > nginx
comparison src/core/ngx_spinlock.c @ 435:5cdc4838d4e8
nginx-0.0.11-2004-09-22-20:18:21 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Wed, 22 Sep 2004 16:18:21 +0000 |
parents | 018569a8f09c |
children | da8c5707af39 |
comparison
equal
deleted
inserted
replaced
434:8998b09f89e9 | 435:5cdc4838d4e8 |
---|---|
3 #include <ngx_core.h> | 3 #include <ngx_core.h> |
4 | 4 |
5 | 5 |
6 void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin) | 6 void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin) |
7 { | 7 { |
8 | |
9 #if (NGX_HAVE_ATOMIC_OPS) | |
10 | |
8 ngx_uint_t tries; | 11 ngx_uint_t tries; |
9 | 12 |
10 tries = 0; | 13 tries = 0; |
11 | 14 |
12 for ( ;; ) { | 15 for ( ;; ) { |
24 if (ngx_atomic_cmp_set(lock, 0, 1)) { | 27 if (ngx_atomic_cmp_set(lock, 0, 1)) { |
25 return; | 28 return; |
26 } | 29 } |
27 } | 30 } |
28 } | 31 } |
32 | |
33 #else | |
34 | |
35 #if (NGX_THREADS) | |
36 | |
37 #error ngx_spinlock() or ngx_atomic_cmp_set() are not defined ! | |
38 | |
39 #endif | |
40 | |
41 #endif | |
42 | |
29 } | 43 } |