aboutsummaryrefslogtreecommitdiff
path: root/src/core/ngx_atomic.h
diff options
context:
space:
mode:
authorIgor Sysoev <igor@sysoev.ru>2004-06-27 18:01:57 +0000
committerIgor Sysoev <igor@sysoev.ru>2004-06-27 18:01:57 +0000
commitc02473048cee372cb8644e1f2d566431781074d2 (patch)
tree689654cd7b37636279b5587ddd3b45ad6bddbd3c /src/core/ngx_atomic.h
parentb1af9bbcabf1bdbe119366971a2d0f6c3f8f595d (diff)
downloadnginx-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.h14
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_ */