src/os/unix/ngx_thread.h - nginx source code

Data types defined

Macros defined

Source code


  1. /*
  2. * Copyright (C) Igor Sysoev
  3. * Copyright (C) Nginx, Inc.
  4. */


  5. #ifndef _NGX_THREAD_H_INCLUDED_
  6. #define _NGX_THREAD_H_INCLUDED_


  7. #include <ngx_config.h>
  8. #include <ngx_core.h>

  9. #if (NGX_THREADS)

  10. #include <pthread.h>


  11. typedef pthread_mutex_t  ngx_thread_mutex_t;

  12. ngx_int_t ngx_thread_mutex_create(ngx_thread_mutex_t *mtx, ngx_log_t *log);
  13. ngx_int_t ngx_thread_mutex_destroy(ngx_thread_mutex_t *mtx, ngx_log_t *log);
  14. ngx_int_t ngx_thread_mutex_lock(ngx_thread_mutex_t *mtx, ngx_log_t *log);
  15. ngx_int_t ngx_thread_mutex_unlock(ngx_thread_mutex_t *mtx, ngx_log_t *log);


  16. typedef pthread_cond_t  ngx_thread_cond_t;

  17. ngx_int_t ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log);
  18. ngx_int_t ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log);
  19. ngx_int_t ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log);
  20. ngx_int_t ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx,
  21.     ngx_log_t *log);


  22. #if (NGX_LINUX)

  23. typedef pid_t      ngx_tid_t;
  24. #define NGX_TID_T_FMT         "%P"

  25. #elif (NGX_FREEBSD)

  26. typedef uint32_t   ngx_tid_t;
  27. #define NGX_TID_T_FMT         "%uD"

  28. #elif (NGX_DARWIN)

  29. typedef uint64_t   ngx_tid_t;
  30. #define NGX_TID_T_FMT         "%uL"

  31. #else

  32. typedef uint64_t   ngx_tid_t;
  33. #define NGX_TID_T_FMT         "%uL"

  34. #endif

  35. ngx_tid_t ngx_thread_tid(void);

  36. #define ngx_log_tid           ngx_thread_tid()

  37. #else

  38. #define ngx_log_tid           0
  39. #define NGX_TID_T_FMT         "%d"

  40. #endif


  41. #endif /* _NGX_THREAD_H_INCLUDED_ */