Mercurial > hg > nginx
diff src/core/ngx_atomic.h @ 370:54f76b0b8dca
nginx-0.0.7-2004-06-27-22:01:57 import
author | Igor Sysoev <igor@sysoev.ru> |
---|---|
date | Sun, 27 Jun 2004 18:01:57 +0000 |
parents | 1526e7686b20 |
children | 780e93985b93 |
line wrap: on
line diff
--- 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_ */