forked from chronolaw/annotated_nginx
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathngx_thread_cond.c
76 lines (54 loc) · 1.3 KB
/
ngx_thread_cond.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
/*
* Copyright (C) Igor Sysoev
* Copyright (C) Nginx, Inc.
*/
#include <ngx_config.h>
#include <ngx_core.h>
ngx_int_t
ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log)
{
ngx_err_t err;
err = pthread_cond_init(cond, NULL);
if (err == 0) {
return NGX_OK;
}
ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_init() failed");
return NGX_ERROR;
}
ngx_int_t
ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log)
{
ngx_err_t err;
err = pthread_cond_destroy(cond);
if (err == 0) {
return NGX_OK;
}
ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_destroy() failed");
return NGX_ERROR;
}
ngx_int_t
ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log)
{
ngx_err_t err;
err = pthread_cond_signal(cond);
if (err == 0) {
return NGX_OK;
}
ngx_log_error(NGX_LOG_EMERG, log, err, "pthread_cond_signal() failed");
return NGX_ERROR;
}
ngx_int_t
ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx,
ngx_log_t *log)
{
ngx_err_t err;
err = pthread_cond_wait(cond, mtx);
#if 0
ngx_time_update();
#endif
if (err == 0) {
return NGX_OK;
}
ngx_log_error(NGX_LOG_ALERT, log, err, "pthread_cond_wait() failed");
return NGX_ERROR;
}