diff options
author | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2017-01-17 20:00:00 +0300 |
commit | 16cbf3c076a0aca6d47adaf3f719493674cf2363 (patch) | |
tree | e6530480020f62a2bdbf249988ec3e2a751d3927 /src/nxt_semaphore.h | |
download | unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.gz unit-16cbf3c076a0aca6d47adaf3f719493674cf2363.tar.bz2 |
Initial version.
Diffstat (limited to 'src/nxt_semaphore.h')
-rw-r--r-- | src/nxt_semaphore.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/nxt_semaphore.h b/src/nxt_semaphore.h new file mode 100644 index 00000000..d1985342 --- /dev/null +++ b/src/nxt_semaphore.h @@ -0,0 +1,32 @@ + +/* + * Copyright (C) Igor Sysoev + * Copyright (C) NGINX, Inc. + */ + +#ifndef _NXT_UNIX_SEMAPHORE_H_INCLUDED_ +#define _NXT_UNIX_SEMAPHORE_H_INCLUDED_ + + +#if (NXT_HAVE_SEM_TIMEDWAIT) + +typedef sem_t nxt_sem_t; + +#else + +typedef struct { + nxt_atomic_t count; + nxt_thread_mutex_t mutex; + nxt_thread_cond_t cond; +} nxt_sem_t; + +#endif + + +NXT_EXPORT nxt_int_t nxt_sem_init(nxt_sem_t *sem, nxt_uint_t count); +NXT_EXPORT void nxt_sem_destroy(nxt_sem_t *sem); +NXT_EXPORT nxt_int_t nxt_sem_post(nxt_sem_t *sem); +NXT_EXPORT nxt_err_t nxt_sem_wait(nxt_sem_t *sem, nxt_nsec_t timeout); + + +#endif /* _NXT_UNIX_SEMAPHORE_H_INCLUDED_ */ |