diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-06-27 18:01:57 +0000 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-06-27 18:01:57 +0000 |
commit | c02473048cee372cb8644e1f2d566431781074d2 (patch) | |
tree | 689654cd7b37636279b5587ddd3b45ad6bddbd3c /src/core/ngx_atomic.h | |
parent | b1af9bbcabf1bdbe119366971a2d0f6c3f8f595d (diff) | |
download | nginx-c02473048cee372cb8644e1f2d566431781074d2.tar.gz nginx-c02473048cee372cb8644e1f2d566431781074d2.zip |
nginx-0.0.7-2004-06-27-22:01:57 import
Diffstat (limited to 'src/core/ngx_atomic.h')
-rw-r--r-- | src/core/ngx_atomic.h | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/src/core/ngx_atomic.h b/src/core/ngx_atomic.h index 5511ea765..bbf4a7685 100644 --- a/src/core/ngx_atomic.h +++ b/src/core/ngx_atomic.h @@ -93,4 +93,18 @@ typedef volatile uint32_t ngx_atomic_t; #endif +static ngx_inline ngx_int_t ngx_trylock(ngx_atomic_t *lock) +{ + if (*lock) { + return NGX_BUSY; + } + + if (ngx_atomic_cmp_set(lock, 0, 1)) { + return NGX_OK; + } + + return NGX_BUSY; +} + + #endif /* _NGX_ATOMIC_H_INCLUDED_ */ |